Skip to content
Snippets Groups Projects
Unverified Commit 6c6d0ae7 authored by Seamus Lee's avatar Seamus Lee Committed by GitHub
Browse files

Merge pull request #495 from seanmadsen/pre-post-hooks

Refer to example of good way to add pre/post hooks to core
parents fd2425ba 229d8e18
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,9 @@ deleted first).
!!! note
These hooks use database transactions. Don't execute code that updates the same data in the database without using a callback. Eg. if triggering on a `Membership` entity, don't try and update that membership entity within the hook. Use CRM_Core_Transaction::addCallback() instead.
!!! tip
Some of the more esoteric entities may not fire this hook when they're saved. If you happen to find such an entity, please make a PR to core which adds this hook. As an example, you can refer to `CRM_Core_BAO_Dashboard::create()` to find succinct syntax that appropriately calls both `CRM_Utils_Hook::pre()` and `CRM_Utils_Hook::post()`.
## Definition
......@@ -65,6 +67,7 @@ hook_civicrm_post($op, $objectName, $objectId, &$objectRef)
expressed an interest to perform an action when a profile is
created/edited)*
- 'Relationship'
- 'Survey' (from 5.1.x)
- 'Tag'
- 'UFMatch' *(when an object is linked to a CMS user record, at the
request of GordonH. A UFMatch object is passed for both the pre
......
......@@ -15,6 +15,9 @@ constraints etc (when deleting an object, the child objects have to be
deleted first). Another good use for the pre hook is to see what is
changing between the old and new data.
!!! tip
Some of the more esoteric entities may not fire this hook when they're saved. If you happen to find such an entity, please make a PR to core which adds this hook. As an example, you can refer to `CRM_Core_BAO_Dashboard::create()` to find succinct syntax that appropriately calls both `CRM_Utils_Hook::pre()` and `CRM_Utils_Hook::post()`.
## Definition
hook_civicrm_pre($op, $objectName, $id, &$params)
......@@ -35,32 +38,33 @@ changing between the old and new data.
objects only)
- $objectName - can have the following values:
- 'Activity'
- 'Campaign' (from 4.6)
- 'Contribution'
- 'ContributionRecur'
- 'CustomGroup'
- 'EntityTag' (from 4.7.16)
- 'Event'
- 'Individual'
- 'Household'
- 'Organization'
- 'Group'
- 'GroupContact'
- 'Relationship'
- 'Activity'
- 'Contribution'
- 'Profile' (while this is not really an object, people have
expressed an interest to perform an action when a profile is
created/edited)
- 'Membership'
- 'MembershipPayment'
- 'MessageTemplate'
- 'Event'
- 'Organization'
- 'Participant'
- 'ParticipantPayment'
- 'Pledge'
- 'PledgePayment'
- 'Profile' (while this is not really an object, people have
expressed an interest to perform an action when a profile is
created/edited)
- 'Relationship'
- 'Survey' (from 5.1.x)
- 'UFMatch' (when an object is linked to a CMS user record, at the
request of GordonH. A UFMatch object is passed for both the pre
and post hooks)
- PledgePayment
- ContributionRecur
- Pledge
- CustomGroup
- 'Campaign' (from 4.6)
- 'EntityTag' (from 4.7.16)
**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment