I needed to be able to send notification email to the event author, so I added token support to this field. In signup.module at the bottom of function signup_send_confirmation_mail,
$forwarding_email = $node->signup_forwarding_email;
if (module_exists('token')) {
$params['body'] = token_replace_multiple($params['body'], array('node' => $node, 'signup' => $signup, 'global' => NULL));
$forwarding_email = token_replace($forwarding_email, 'node', $node);
}
$language = user_preferred_language($signup);
return drupal_mail('signup', 'signup_forwarding_mail', $forwarding_email, $language, $params, $from);
token_replace could probably be done similarly to the replacement in the line above for 'body', but I only needed it for node so that I could set the email address to be "[author-mail]". This works fine for sending the signup notifications to the event author.
Comments
Comment #1
cybermache commentedI tried this patch on both rc6 and current dev versions and both created errors and [author-mail] was not replaced by anything. Am I missing something here. Is there some other place that I need to add code to or a settings that need adjustment after implementing this patch?
Comment #2
adraskoy commentedWhat errors did you get?
Comment #3
cybermache commentedError type was 'mail'
Error message was 'Error sending e-mail (from "site-email" to [author-mail]).'
"Site-email" is replacing the default email entered on the admin/settings/site-information page. Since this is off a test site I thought it unnecessary to provide that information. [author-mail] is the exact value entered in the 'Send signups to' field on the admin/settings/signup page.
Comment #4
adraskoy commentedLooks like it's not finding that token. Check the replacement values listed on the settings page and ensure that [author-mail] is listed.
Comment #5
cybermache commentedthese two are listed under the replacement values on the settings page.
[author-mail] The email address of the author of the node.
[author-mail-raw] The email address of the author of the node. Warning: Token value contains raw user input.
Comment #6
adraskoy commentedAll I can suggest is that you place some debugging calls around this line:
and try and find out why the token is not being replaced on your test instance.
Comment #7
bk262 commentedThe code snippet must not be replaced in the function signup_send_confirmation_mail but in the function signup_send_forwarding_mail. Than it works :)
Comment #8
adraskoy commentedThanks bk262 - don't know how I managed that!
Comment #9
cybermache commentedWith bk262's correction the patch works well for us now. Thanks a bunch adraskoy and bk262 this has given us many more ways to use this module.
Comment #10
cybermache commentedThis patch no longer works with the recent version of Signup 6.x-1.0. I repatched it with the previously working code and it kicks out an error message that mail could not be sent. [author-mail] is not being replaced by the Signup author's email.
Comment #11
cybermache commentedI just installed the latest dev version of Signup 6.x-1.x-dev (2011-Dec-01). Instead of doing the patch above I just added the line below.
This seems to work just fine. Not sure why the other way didn't work at all with the latest dev version.
Comment #12
PascalAnimateur commentedFor signup-7.x, this line should be :
$node->signup_forwarding_email = token_replace($node->signup_forwarding_email, array('node' => $node));Comment #13
jerenus commentedQuick fixed to 7.x