Commit 4b9a3cf7 authored by Dries's avatar Dries
Browse files

- Patch #4942 by webchik et al: e-mail verification is optional now.

parent fb7ebf2f
......@@ -31,6 +31,7 @@ Drupal x.x.x, xxxx-xx-xx (development version)
* 'blogapi new' and 'blogapi edit' nodeapi operations.
- user module:
* added hook_profile_alter().
* e-mail verification is made optional.
- PHP Template engine:
* add the ability to look for a series of suggested templates.
* look for page templates based upon the path.
......
......@@ -1184,7 +1184,12 @@ function user_register_submit($form_id, $form_values) {
$mail = $form_values['mail'];
$name = $form_values['name'];
$pass = $admin ? $form_values['pass'] : user_password();
if (!variable_get('user_email_verification', TRUE) || $admin) {
$pass = $form_values['pass'];
}
else {
$pass = user_password();
};
$notify = $form_values['notify'];
$from = variable_get('site_mail', ini_get('sendmail_from'));
if (isset($form_values['roles'])) {
......@@ -1213,6 +1218,14 @@ function user_register_submit($form_id, $form_values) {
if ($admin && !$notify) {
drupal_set_message(t('Created a new user account. No e-mail has been sent.'));
}
else if (!variable_get('user_email_verification', TRUE) && $account->status && !$admin) {
// No e-mail verification is required, create new user account, and login user immediately.
$subject = _user_mail_text('welcome_subject', $variables);
$body = _user_mail_text('welcome_body', $variables);
drupal_mail('user-register-welcome', $mail, $subject, $body, $from);
user_authenticate($account->name, trim($pass));
drupal_goto();
}
else if ($account->status || $notify) {
// Create new user account, no administrator approval required.
$subject = $notify ? _user_mail_text('admin_subject', $variables) : _user_mail_text('welcome_subject', $variables);
......@@ -1266,15 +1279,13 @@ function user_edit_form($uid, $edit, $register = FALSE) {
);
if (!$register) {
$form['account']['pass'] = array('#type' => 'password_confirm',
'#title' => t('Password'),
'#description' => t('To change the current user password, enter the new password in both fields.'),
);
}
elseif ($register && $admin) {
$form['account']['pass'] = array('#type' => 'password',
'#title' => t('Password'),
'#size' => 30,
'#description' => t('Provide a password for the new account.'),
elseif (!variable_get('user_email_verification', TRUE) || $admin) {
$form['account']['pass'] = array(
'#type' => 'password_confirm',
'#description' => t('Provide a password for the new account in both fields.'),
'#required' => TRUE,
);
}
......@@ -1912,7 +1923,8 @@ function user_admin_settings() {
// User registration settings.
$form['registration'] = array('#type' => 'fieldset', '#title' => t('User registration settings'));
$form['registration']['user_register'] = array('#type' => 'radios', '#title' => t('Public registrations'), '#default_value' => variable_get('user_register', 1), '#options' => array(t('Only site administrators can create new user accounts.'), t('Visitors can create accounts and no administrator approval is required.'), t('Visitors can create accounts but administrator approval is required.')));
$form['registration']['user_registration_help'] = array('#type' => 'textarea', '#title' => t('User registration guidelines'), '#default_value' => variable_get('user_registration_help', ''), '#description' => t('This text is displayed at the top of the user registration form. It\'s useful for helping or instructing your users.'));
$form['registration']['user_email_verification'] = array('#type' => 'checkbox', '#title' => t('Require e-mail verification when a visitor creates an account'), '#default_value' => variable_get('user_email_verification', TRUE), '#description' => t('If this box is checked, new users will be required to validate their e-mail address prior to logging into to the site, and will be assigned a system-generated password. With it unchecked, users will be logged in immediately upon registering, and may select their own passwords during registration.'));
$form['registration']['user_registration_help'] = array('#type' => 'textarea', '#title' => t('User registration guidelines'), '#default_value' => variable_get('user_registration_help', ''), '#description' => t("This text is displayed at the top of the user registration form. It's useful for helping or instructing your users."));
// User e-mail settings.
$form['email'] = array('#type' => 'fieldset', '#title' => t('User e-mail settings'));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment