Disabling Drupal's default notifications to the administrator when a user registers
This is not tested, but running this code (in an update hook, via Drush php-eval, however) should prevent Drupal from sending its notifications to the site e-mail address when a new, pending approval user registers:
<?php
variable_set('user_mail_register_pending_approval_notify', FALSE);
?>
Motivation
We had configured Drupal core's Action and Trigger modules to send a more informative e-mail when a user requested a user account. (Why does Drupal core not enable and use its own core modules, so this would be configurable through there? Good question!) We do not want to send duplicate, less useful e-mails.
Figuring it Out
Working backwards from case 'register_pending_approval_admin_body' in a switch statement in _user_mail_text(), we can see that user_mail must be passing it the key 'register_pending_approval_admin' to produce that value.
It is therefore being called by the code:
<?php
drupal_mail('user', 'register_pending_approval_admin', variable_get('site_mail', ini_get('sendmail_from')), language_default(), $params);
?>
which is wrapped in an if statement checking for the $op 'register_pending_approval'.
This is in the function _user_mail_notify, which is handed in that op.
The exciting thing is that it checks for:
<?php
$notify = variable_get('user_mail_' . $op . '_notify', $default_notify);
?>
That variable, user_mail_register_pending_approval_notify, cannot be set through the admin interface, but it can be set in the database (as through an update hook) or overridden in settings.php
Comments
Disables user mail as well
I'm using this trick in settings.php and notice that it also disables the triggered email to the new registrant, not just the admin notification. So a custom message also needs to be created to replace that one.
Thanks for posting this!
Post new comment