function email_confirm_user_presave in Email Change Confirmation 7
Implements hook_user_presave().
File
- ./
email_confirm.module, line 192 - The Email Change Confirmation module.
Code
function email_confirm_user_presave(&$edit, $account, $category) {
if (!empty($edit['mail']) && (!empty($account->mail) && drupal_strtolower($account->mail) != drupal_strtolower($edit['mail'])) && !user_access('bypass email confirmation') && !drupal_installation_attempted() && (!isset($edit['email_confirmed']) || $edit['email_confirmed'] === FALSE)) {
// Set a temporary session variable to indicate that the email was
// changed. Is used in hook_exit to clear out a Drupal message set
// by the user module after user_save() is called.
$_SESSION['email_changed'] = TRUE;
email_confirm_build_mail($edit, $account);
$edit['data']['email_confirm']['pending_email'] = $edit['mail'];
$edit['data']['email_confirm']['expiration_time'] = REQUEST_TIME + 86400;
module_invoke_all('email_confirm', 'email change', $account->uid, $account->mail, $edit['mail']);
if (module_exists('rules')) {
rules_invoke_event('email_confirm_email_change_request', $account, $account->mail, $edit['mail']);
}
unset($edit['mail']);
unset($edit['email_confirmed']);
}
if (isset($edit['email_confirmed']) && $edit['email_confirmed'] === TRUE || !empty($edit['data']) && isset($edit['data']['email_confirm']) && $edit['data']['email_confirm']['expiration_time'] < REQUEST_TIME) {
unset($edit['data']['email_confirm']);
}
}