function logintoboggan_mail_alter in LoginToboggan 7
Implement hook_mail_alter().
File
- ./
logintoboggan.module, line 1155 - LoginToboggan module
Code
function logintoboggan_mail_alter(&$message) {
if ($message['id'] == 'user_register_pending_approval_admin') {
$reg_pass_set = !variable_get('user_email_verification', TRUE);
if ($reg_pass_set) {
$account = $message['params']['account'];
$url_options = array(
'absolute' => TRUE,
);
$language = $message['language'];
$langcode = isset($language) ? $language->language : NULL;
$message['body'][] = t("\n\nThe user has automatically received the permissions of the LoginToboggan validating role. To give the user full site permissions, click the link below:\n\n!validation_url/admin\n\nAlternatively, you may visit their user account listed above and remove them from the validating role.", array(
'!validation_url' => logintoboggan_eml_validate_url($account, $url_options),
), array(
'langcode' => $langcode,
));
}
}
// Pre-authorized users are logged in to the site without having validated
// their e-mail address. This allows users to register using other people's
// e-mail addresses. To prevent potential abuse we block all e-mails to
// pre-authorized users, except the ones that are needed to recover a lost
// account or to create a new one.
$validating_id = logintoboggan_validating_id();
$pre_auth = !variable_get('user_email_verification', TRUE) && $validating_id != DRUPAL_AUTHENTICATED_RID;
$account = user_load_by_mail($message['to']);
if ($pre_auth && !empty($account->roles) && array_key_exists($validating_id, $account->roles)) {
$whitelist = array(
'user_cancel_confirm',
'user_password_reset',
'user_register_admin_created',
'user_register_no_approval_required',
'user_register_pending_approval',
'user_status_blocked',
'user_status_canceled',
);
// Allow other modules to alter the e-mail whitelist.
drupal_alter('logintoboggan_pre_auth_whitelist', $whitelist);
$message['send'] = in_array($message['id'], $whitelist);
watchdog('logintoboggan', 'Message to non-authenticated user email %sendto blocked.', array(
'%sendto' => $message['to'],
));
}
}