I have set up a hook to assign a group to new contacts when they are created. I have set it up the old-fashioned way, ie with a function called joomla_civicrm_post in a file called civicrmHooks.php in the php override directory. But the function is called every time the master cron job fires, whereas I expected/wanted it to be called when a new contact is created. Have I missed something obvious? Should this work? Or do I have to implement the hook as a Joomla plugin in order to get it to trigger correctly? Thanks.

Joomla 3.6.5, CiviCRM 4.7.16, php 5.6.30


OK, it was my stupid fault. The function isn't only called when a contact is created - it's called when any event happens (eg cron job). So the important line is the conditional statement (which should be the first line of the function) which decides whether the function should continue. In my case, this conditional line was:

IF ( ($objectName != 'Individual' && $objectName != 'Organization') || $op != 'create') { return; }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.