In Drupal 7...
I am trying to find a solution to disable the sending of the user mail register by admin for certain roles. I have scoured the internet and have come up with using a combo of mailcontrol and Rules or custom code in my module.
I'm using Rules to send the message. I didn't want to completely disable the welcome email message for the other roles.
How can I create this functionality of sending the system mail to some users but not others? (either programmatically or via Rules)
I have a custom module already, so I used the following hook but nothing happened. I still get the welcome message.
function myMod_fields_user_mail_notify($op, $account, $language = NULL) {
$notify = variable_get('user_mail_' . $op . '_notify', $default_notify);
if (in_array('Administrator', $user->roles)) {
if ($op == 'register_admin_created') {
//don't send system email we'll do this with another rule.
variable_set('user_mail_register_admin_created_notify', false);
}
else if ($notify) {
$params['account'] = $account;
$language = $language ? $language : user_preferred_language($account);
$mail = drupal_mail('user', $op, $account->mail, $language, $params);
}
return empty($mail) ? NULL : $mail['result'];
}
}