User login

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

Searched words: 
drupal 7 disable notification when user registers

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

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.