I'm porting some code using Civi hooks from Civi 4.4 to 4.6 . The code needs to know when a relationship becomes active or inactive, regardless of how that happens, including via the enable/disable links on the Relationships tab.

My implementation for 4.4 used both hook_civicrm_post and hook_civicrm_enableDisable. In Civi 4.6, hook_civicrm_enableDisable has been removed. I've found that hook_civicrm_post gets called when the enable/disable links are used but the CRM_Contact_DAO_Relationship object passed in only has the id field populated, all the other fields are blank.

Is this a bug and so should be addressed in core, or intended behaviour and so something I have to work around in my hook implementation?

I'm using CiviCRM 4.6.4 with Drupal 7.


1 Answer 1


Sorry but it's the intended behavior. Generally pre and post hooks just pass whatever happens to be loaded in that object rather than taking the performance hit of doing a full database load for the sake of a hook which may or may not be implemented and may or may not care.

I recommend not relying on the object being passed to pre/post hooks and doing your own api lookup using the provided id.

  • Thanks for confirming, Coleman. I think this is the first case I've come across of a post hook not receiving a populated object for op = 'edit'. However hook_civicrm_enableDisable wasn't receiving one, so in that sense I'm no worse off. Better be extra-careful with post hooks now though.
    – davejenx
    Jul 13, 2015 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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