Skip to content

Instantly share code, notes, and snippets.

@init90
Last active July 13, 2018 21:46
Show Gist options
  • Save init90/9169230dd165e6de4bfbd9a8d77662e5 to your computer and use it in GitHub Desktop.
Save init90/9169230dd165e6de4bfbd9a8d77662e5 to your computer and use it in GitHub Desktop.
Drupal 7, Disable mail sending if condition is right.
/**
* Implements hook_mail_alter().
*/
function MYMODULE_mail_alter(&$message) {
if ($message['key'] == 'register_confirmation_with_pass') {
$user = $message['params']['account'];
// If user account need to approve we ignore standard mail after registration
// because we have custom mails for this case.
if (lb_registration_account_need_to_approve($user)) {
$message['send'] = FALSE;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment