=== modified file 'modules/user/user.module' --- modules/user/user.module +++ modules/user/user.module @@ -1175,7 +1175,12 @@ function user_register_submit($form_id, $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'])) { @@ -1208,6 +1213,14 @@ function user_register_submit($form_id, 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); @@ -1265,7 +1278,7 @@ function user_edit_form($uid, $edit, $re '#description' => t('To change the current user password, enter the new password in both fields.'), ); } - elseif ($register && $admin) { + elseif (!variable_get('user_email_verification', TRUE) || $admin) { $form['account']['pass'] = array('#type' => 'password', '#title' => t('Password'), '#size' => 30, @@ -1316,6 +1329,7 @@ function _user_edit_validate($uid, &$edi } // Validate the e-mail address: + if ( variable_get('user_email_verification', TRUE) ) { if ($error = user_validate_mail($edit['mail'])) { form_set_error('mail', $error); } @@ -1325,6 +1339,7 @@ function _user_edit_validate($uid, &$edi else if (drupal_is_denied('mail', $edit['mail'])) { form_set_error('mail', t('The e-mail address %email has been denied access.', array('%email' => theme('placeholder', $edit['mail'])))); } + } // If required, validate the uploaded picture. if ($file = file_check_upload('picture_upload')) { @@ -1907,6 +1922,7 @@ 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_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('Uncheck this box to allow new registrants to create own password and immediately login.')); $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.