Skip to content

Instantly share code, notes, and snippets.

@SebCorbin
Created May 12, 2012 22:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SebCorbin/2669582 to your computer and use it in GitHub Desktop.
Save SebCorbin/2669582 to your computer and use it in GitHub Desktop.
Send pending approval mails to all users who have the 'administer users' permission
<?php
/**
* Implements hook_mail_alter().
*
* Also send pending approval mails to users who have
* the 'administer users' permission
*
* @see _user_mail_notify()
*/
function mymodule_mail_alter(&$message) {
if ($message['id'] == 'user_register_pending_approval_admin' && !isset($message['params']['stop_propagation'])) {
$message['params']['stop_propagation'] = TRUE;
$roles = user_roles(TRUE, 'administer users');
$uids = db_select('users_roles', 'ur')
->fields('ur', array('uid'))
->condition('rid', array_keys($roles))
->execute()
->fetchCol();
$users = user_load_multiple($uids);
foreach ($users as $account) {
drupal_mail('user', 'register_pending_approval_admin', $account->mail,user_preferred_language($account), $message['params']);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment