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

cybermache’s picture

I 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?

adraskoy’s picture

What errors did you get?

cybermache’s picture

Error 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.

adraskoy’s picture

Looks like it's not finding that token. Check the replacement values listed on the settings page and ensure that [author-mail] is listed.

cybermache’s picture

these 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.

adraskoy’s picture

All I can suggest is that you place some debugging calls around this line:

  $forwarding_email = token_replace($forwarding_email, 'node', $node);

and try and find out why the token is not being replaced on your test instance.

bk262’s picture

The code snippet must not be replaced in the function signup_send_confirmation_mail but in the function signup_send_forwarding_mail. Than it works :)

adraskoy’s picture

Thanks bk262 - don't know how I managed that!

cybermache’s picture

With 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.

cybermache’s picture

This 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.

cybermache’s picture

I 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.

  if (module_exists('token')) {
    $params['body'] = token_replace_multiple($params['body'], array('node' => $node, 'signup' => $signup, 'global' => NULL));
 +   $node->signup_forwarding_email = token_replace($node->signup_forwarding_email, 'node', $node);
  }
  $language = user_preferred_language($signup);
  return drupal_mail('signup', 'signup_forwarding_mail', $node->signup_forwarding_email, $language, $params, $from);
}

This seems to work just fine. Not sure why the other way didn't work at all with the latest dev version.

PascalAnimateur’s picture

For signup-7.x, this line should be :
$node->signup_forwarding_email = token_replace($node->signup_forwarding_email, array('node' => $node));

jerenus’s picture

Version: 6.x-1.0-rc6 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new971 bytes

Quick fixed to 7.x