Is there a way to change where the user registration notification email goes to? Right now it goes to the email address specified in Administration » Configuration » System » Site information. I would like to make it go to another email instead.

I prefer to do it through code or the Drupal admin and not add another module.

Could I do this using hook_form_alter targeting "user_register_form" or is there another way?


deruitern’s picture

You should be able to change the To address of an email by creating a custom module and implementing hook_mail_alter.

systemick’s picture

I did something similar to this recently. The code looked something like this:

function mymodule_mail_alter(&$message) {
  if ($message['id'] == $my_id) {
    $email_address = mymodule_get_manager_email($gid);
    $message['to'] = $email_address;
kraken’s picture

Thanks, your suggestion helped me do it. If anyone else is looking to do this, the message ids I used are:

['id'] == "user_register_pending_approval"; // for email to registrant
$message['id'] == "user_register_pending_approval_admin"; // // for email to admin
zkent’s picture

I just did this by creating a rule in D7.

Event: After saving a new user account
Conditions: Entity is of type: User AND Data Comparison: Account:Status == Blocked (so no email is sent if account created by admin.)
Actions: Send mail to all users of a role (this could also be a specific email address)

fonant’s picture

The condition "User is blocked" is simpler. - Fonant Ltd - Quality websites