I am trying to make a rule which when acted upon will send an email with custom details based on the rule arguments.
I made my rule event and that's all working fine it shows up, but when I add an action to "Send mail
" and then look at all of the Replacement patterns
non of my tokens show up, only site-information tokens show up.
Token Functions
/**
* Implementation of hook_token_list()
*/
function mahjong_token_list($type = 'all') {
if ($type == 'all' || $type == 'mahjong') {
$tokens['mahjong'] = array(
'package_name' => t('The name of the package'),
);
}
return $tokens;
}
/**
* Implementation of hook token api
*/
function mahjong_token_values($type, $object = NULL, $options = array()) {
$tokens = array();
var_dump($object);
if ($object) {
if ($type == 'mahjong') {
$tokens = array(
'user_name' => $object->name,
'user_email' => $object->email,
'user_score' => $object->score,
);
}
}
return $tokens;
}
Rules Function
function mahjong_rules_event_info() {
return array(
'mahjong_won' => array(
'label' => t('A person won the mahjong game.'),
'module' => 'mahjong',
'group' => 'Rules',
'arguments' => array(
'user' => array('type' => 'mahjong', 'label' => t('The user who won the mahjong game.')),
),
),
);
}
What am I doing wrong? How can I get the data from the rules argument pass to the action to send an email?