function _user_registrationpassword_user_pass_submit in User registration password 7
Same name and namespace in other branches
- 8 user_registrationpassword.module \_user_registrationpassword_user_pass_submit()
Implements submit function.
1 string reference to '_user_registrationpassword_user_pass_submit'
File
- ./
user_registrationpassword.module, line 598 - Enables password creation on registration form.
Code
function _user_registrationpassword_user_pass_submit(&$form, &$form_state) {
$account = $form_state['values']['account'];
// Then, if we have a user account
// and it has never ever been used.
if (!empty($account->uid) && !$account->login && !$account->access && !$account->status) {
// Try to load the account in disabled state.
$users = user_load_multiple(array(
$account->uid,
), array(
'login' => '0',
'access' => '0',
'status' => '0',
));
$user = reset($users);
// If the user never ever logged in, resend the activation mail.
if (!empty($user)) {
// Mail one time login URL and instructions using current language.
$params['account'] = $user;
// And on success, throw a message.
if (drupal_mail('user_registrationpassword', 'register', $user->mail, user_preferred_language($user), $params)) {
watchdog('user', 'Password reset instructions mailed to %name at %email.', array(
'%name' => $user->name,
'%email' => $user->mail,
));
user_registrationpassword_set_message();
}
}
}
else {
// If we found no errors execute core submission handler.
// Obviously cache is disabled on this pages, so this should work.
if (empty($_SESSION['messages']['error'])) {
user_pass_submit($form, $form_state);
}
}
}