EDIT
This answer is now deprecated, you should use @bgm's answer instead., or for an alternative and possibly cleaner approach, try my other answer
All thanks to the code example link in Eric's answer here's a simplified example of how to offer up a hook (my_new_hook
) which takes one argument, $the_argument
:
CRM_Utils_Hook::singleton()->invoke(
1, $the_argument,
$dummy, $dummy, $dummy, $dummy, $dummy,
'my_new_hook');
Then other extensions can include functions like
function myextension_my_new_hook($arg) {
do_something_with($arg);
}
The $dummy
is just because we must pass a variable (since it's passed by reference), but this hook does not need it. If you had a hook that took two arguments, you'd use 2
in place of 1
and replace the first $dummy
with your actual second argument etc. up to 6.
Nb. this code assumes CiviCRM 4.5+, but obviously you're not using anything older than that these days, right?!