hook_civicrm_tokens
Home > Developer Guide > Hooks > Token Hooks/listeners ~~# hook_civicrm_tokens~~
Deprecated - use the token Processor
Summary
This hook is called to allow custom tokens to be defined.
Notes
The token values will need to be supplied by hook_civicrm_tokenValues.
See this article for usage examples.
Definition
hook_civicrm_tokens(&$tokens)
Parameters
- $tokens: reference to the associative array of custom tokens that are available to be used in mailings and other contexts. This will be an empty array unless an implementation of hook_civicrm_tokens adds items to it. Items should be added in this format:
$tokens['date'] = [
'date.date_short' => ts("Today's Date: short format"),
'date.date_med' => ts("Today's Date: med format"),
'date.date_long' => ts("Today's Date: long format"),
];
$tokens['party'] = [
'party.balloons' => ts("Number of balloons"),
];
Returns
- null
Example
function customtokens_civicrm_tokens(&$tokens) {
$tokens['team'] = [
'team.team_number' => 'Team number',
];
}