Index: logintoboggan.module =================================================================== --- logintoboggan.module (revision 3336) +++ logintoboggan.module (working copy) @@ -281,7 +281,8 @@ $validating_id = logintoboggan_validating_id(); $roles = isset($form_values['roles']) ? array_filter($form_values['roles']) : array(); if ($reg_pass_set && ($validating_id > DRUPAL_AUTHENTICATED_RID)) { - $roles[$validating_id] = 1; + $form_values['need_validated'] = 1; + unset($form_values['pre_validated']); } $account = user_save('', array_merge($form_values, array('pass' => $pass, 'init' => $mail, 'roles' => $roles, 'status' => $status))); @@ -290,10 +291,10 @@ $login_url = variable_get('user_register', 1) == 1 ? logintoboggan_eml_validate_url($account) : user_pass_reset_url($account); $variables = array('!username' => $name, '!site' => variable_get('site_name', 'drupal'), '!password' => $pass, '!uri' => $base_url, '!uri_brief' => substr($base_url, strlen(_logintoboggan_protocol() .'://')), '!mailto' => $mail, '!date' => format_date(time()), '!login_uri' => url('user', NULL, NULL, TRUE), '!edit_uri' => url('user/'. $account->uid .'/edit', NULL, NULL, TRUE), '!login_url' => $login_url); - + $already_confirmed = $pre_auth && !isset($account->roles[$validating_id]); // Compose the appropriate user message--admin approvals don't require a validation e-mail. if($reg_pass_set && variable_get('user_register', 1) == 1) { - if ($pre_auth) { + if ($pre_auth && !$already_confirmed) { $message = t('A validation e-mail has been sent to your e-mail address. In order to gain full access to the site, you will need to follow the instructions in that message.'); } else { @@ -304,12 +305,14 @@ } if (variable_get('user_register', 1) == 1) { - // Create new user account, no administrator approval required. - $subject = _user_mail_text('welcome_subject', $variables); - $body = _user_mail_text('welcome_body', $variables); - $mailkey = 'user-register-welcome'; + // No need to send email if we are already authenticated. + if (!$already_confirmed) { + $subject = _user_mail_text('welcome_subject', $variables); + $body = _user_mail_text('welcome_body', $variables); + $mailkey = 'user-register-welcome'; + } } elseif (variable_get('user_register', 1) == 2) { // Create new user account, administrator approval required. @@ -331,7 +334,8 @@ } //mail the user. - drupal_mail($mailkey, $mail, $subject, $body, $from); + if ($mailkey) + drupal_mail($mailkey, $mail, $subject, $body, $from); drupal_set_message($message); @@ -947,6 +951,11 @@ } } } + elseif ($op == 'insert') { + if ($edit['need_validated'] && !$edit['pre_validated']) { + $edit['roles'][logintoboggan_validating_id()] = 1; + } + } } /**