Create new customPre hook
I'd like to create a new "customPre" hook that is fired prior to a custom field being stored in the DB. Currently we have a "custom" hook which is fired after a custom field is stored, but no way to impact the process prior to storing. See also: https://civicrm.stackexchange.com/questions/35354/is-there-a-hook-to-impact-custom-data-before-its-saved/35364#35364
- why this is needed: there's currently no way to alter custom data before it is stored, or to do thing like check the existing value for the field prior to the update (in order to, for example, trigger a secondary action). Custom data currently does not hit the pre/post hooks.
- why not try to implement the existing "pre" hook in this context? we could potentially do that, but the custom data model is a little different from a standard object. For example, the custom group ID is useful to have available but is not part of the actual insert/update query for custom data. It seems more useful to follow the existing pattern with the "custom" hook. While we could pass that additional metadata as part of the pre hook's params, it would deviate from how that hook is implemented elsewhere.
The hook would be implemented in CRM_Core_BAO_CustomValueTable::create(), and would follow the pattern of how the "custom" hook is implemented there.
Looking for feedback and concept approval.