function user_registrationpassword_form_user_register_submit in User registration password 6
Same name and namespace in other branches
- 8 user_registrationpassword.module \user_registrationpassword_form_user_register_submit()
- 7 user_registrationpassword.module \user_registrationpassword_form_user_register_submit()
Submit handler for the user registration form.
1 string reference to 'user_registrationpassword_form_user_register_submit'
- user_registrationpassword_form_user_register_alter in ./
user_registrationpassword.module - Implements hook_form_FORM_ID_alter() for the user registration form.
File
- ./
user_registrationpassword.module, line 146 - Enables password creation on registration form.
Code
function user_registrationpassword_form_user_register_submit(&$form, &$form_state) {
// Load the user by e-mail address.
$account = user_load(array(
'mail' => $form_state['values']['mail'],
));
// Save the account as blocked, so users first have to verify
// via e-mail and do not get logged in straight away.
// This is a required step in D6, D7 does not require this.
user_save($account, array(
'status' => 0,
));
// Remove the message sent by default.
$message = t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, a welcome message with further instructions has been sent to your e-mail address.');
$position = array_search($message, $_SESSION['messages']['status']);
if ($position !== FALSE) {
unset($_SESSION['messages']['status'][$position]);
}
$_SESSION['messages']['status'] = array_values($_SESSION['messages']['status']);
// Make sure the password is taken from the form and added to our object.
// This is required to send out passwords via tokens on registration.
$account->password = $form_state['user']->password;
$params['account'] = $account;
// Notify the user and send the e-mail.
$mail = drupal_mail('user_registrationpassword', 'register', $account->mail, user_preferred_language($account), $params);
drupal_set_message(t('A welcome message with further instructions has been sent to your e-mail address.'));
}