Tokens described in hook_pet_substitutions_alter() will not be replaced unless they are real tokens which was implemented using hook_tokens() and etc.
Sometime you need to have custom tokens in your email but they couldn't be tokenized. For example, when you got wrong request and want to send some information to site admin about this request but there is no need to store it to database.
This patch after replacing all existing tokens allow you to replace custom tokens (which actually not tokens at all).
Probably you'll need patch https://drupal.org/node/2087959 to get it working.
Usage:
$params = array(
'message' => t('Error message with code.'),
);
pet_send_mail('lead_provider_' . $mail_key, $recipients, $params);
then you should implement:
/**
* Add custom token objects.
*/
function modulename_pet_substitutions_alter(&$substitutions, $params) {
if (isset($params['pet_options']) && is_array($params['pet_options'])) {
$substitutions['[message]'] = $params['pet_options']['message'];
}
}
Comment | File | Size | Author |
---|---|---|---|
#3 | pet_2088411_3.patch | 1.42 KB | VladSavitsky |
Comments
Comment #1
VladSavitsky CreditAttribution: VladSavitsky commentedComment #2
VladSavitsky CreditAttribution: VladSavitsky commentedComment #3
VladSavitsky CreditAttribution: VladSavitsky commentedFixed issue when user with this email is existing user at site and pet adds user object to the array of substitutions.
Comment #4
sumanthkumarc CreditAttribution: sumanthkumarc at Azri Solutions commentedThe patch works for me. But the replacement must of format $type:$name, otherwise token module won't replace it. Also we need to implement hook_tokens() to replace your custom token.
Comment #5
Sharique CreditAttribution: Sharique as a volunteer commentedIt would be nice, if some tests are written for this.