1

I want to send a notification to a specific email address when a contact opts out from all bulk mailings. Therefor I tried the hook hook_civicrm_post. This should be triggered when the field "NO BULK EMAILS" gets checked. After submitting the opt-out form, the field "NO BULK EMAILS" is checked in the contact's profile but the hook is not triggered. I tested that with the following code:

function module_name_civicrm_post($op, $objectName, $objectId, &$objectRef){
    $dump = 
        print_r($op, true)
        . print_r($objectName, true)
        . print_r($objectId, true)
        . print_r($objectRef, true);
    file_put_contents('/home/civicrm/test/dump.txt', $dump);
}

(I have got write permissions, so that can't be the problem.)

I also changed the field manually in the contact's profile but that also didn't trigger the hook.

Does anyone have an idea why this hook is not invoked or what hook can I use instead?

Philipp Michael
  • 954
  • 1
  • 11
  • 22
  • You should use watchdog to check if the hook is getting triggert. Thus you can exclude possible log file permission problems. – Philipp Michael Nov 22 '16 at 10:24
  • I can confirm that hook_civicrm_post (or _pre) is not beeing triggert when using the opt-out form, but it is triggert when using the contact edit form. – Philipp Michael Nov 22 '16 at 10:26

0 Answers0