Home > Developer Guide > Hooks and events > Deprecated Hooks
~~hook_civicrm_tokens~~
!!! warning "Deprecated Hook" This hook is deprecated. Use the Token Processor instead. This hook is specifically replaced by the civi.token.list Symfony event.
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, bool $squashDeprecation = FALSE)
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"),
];
- $squashDeprecation - Document parameter here.
Returns
- null
Example
function customtokens_civicrm_tokens(&$tokens) {
$tokens['team'] = [
'team.team_number' => 'Team number',
];
}