+++ logintoboggan.module	2009-11-10 15:20:51.000000000 +1100
@@ -624,12 +624,20 @@ function logintoboggan_main_settings() {
   // Grab the roles that can be used for pre-auth.  Remove the anon role, as it's not a valid choice.
   $roles = user_roles(1);
 
-  $form ['registration']['toboggan_role'] = array('#type' => 'select',
+  $form ['registration']['toboggan_preauth_role'] = array('#type' => 'select',
     '#title' => t('Non-authenticated role'),
     '#options' => $roles,
-    '#default_value' => variable_get('toboggan_role', DRUPAL_AUTHENTICATED_RID),
+    '#default_value' => variable_get('toboggan_preauth_role', DRUPAL_AUTHENTICATED_RID),
     '#description' => t('If "Set password & Immediate login" is selected, users will be able to login before their e-mail address has been authenticated. Therefore, you must choose a role for new non-authenticated users. Users will be removed from this role and assigned to the "authenticated user" role once they follow the link in their welcome e-mail. <a href="!url">Add new roles</a>.', array('!url' => url('admin/user/roles'))),
     );
+    
+    $form ['registration']['toboggan_postauth_role'] = array(
+      '#type' => 'select',
+      '#title' => t('Confirmed role'),
+      '#options' => $roles + array('FALSE' => 'N/A'),
+      '#default_value' => variable_get('toboggan_postauth_role', 'FALSE'),
+      '#description' => t('If "Set password" is selected, users will be able to login before their e-mail address has been authenticated. If you would like to assign a role to a user once they confirm their email address, select a role above. <a href="!url">Add new roles</a>. <strong>WARNING: changing this setting after initial site setup can cause undesirable results, including unintended deletion of users -- change with extreme caution!</strong>', array('!url' => url('admin/user/roles'))),
+    );
 
   $form['registration']['redirect'] = array(
     '#type' => 'fieldset',
@@ -775,7 +783,7 @@ function logintoboggan_validate_pass($pa
   * - gets the role id for the "validating" user role.
   */
 function logintoboggan_validating_id() {
-  return variable_get('toboggan_role', DRUPAL_AUTHENTICATED_RID);
+  return variable_get('toboggan_preauth_role', DRUPAL_AUTHENTICATED_RID);
 }
 
 
@@ -873,6 +881,13 @@ function _logintoboggan_process_validati
   // Allow other modules to react to email validation by invoking the user update hook.
   // This should only be triggered if LT's custom validation is active.
   if (!variable_get('user_email_verification', TRUE)) {
+  
+    // If there is a post-confirmation role, assign it
+    $post_auth_rid = variable_get('toboggan_postauth_role', 'FALSE');
+    if (is_numeric($post_auth_rid)) {
+      db_query("INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)", $account->uid, $post_auth_rid);
+    }
+    
     $edit = array();
     $account->logintoboggan_email_validated = TRUE;
     user_module_invoke('update', $edit, $account);
