Created
May 12, 2012 22:53
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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