You are here

function _logintoboggan_process_validation in LoginToboggan 5

Same name and namespace in other branches
  1. 6 logintoboggan.module \_logintoboggan_process_validation()
  2. 7 logintoboggan.module \_logintoboggan_process_validation()
2 calls to _logintoboggan_process_validation()
logintoboggan_form_alter in ./logintoboggan.module
Implementation of hook_form_alter()
logintoboggan_validate_email in ./logintoboggan.module
Menu callback; process validate the e-mail address as a one time URL, and redirects to the user page on success.

File

./logintoboggan.module, line 889
Logintoboggan Module

Code

function _logintoboggan_process_validation($account) {

  // Test here for a valid pre-auth -- if the pre-auth is set to the auth user, we
  // handle things a bit differently.
  $validating_id = logintoboggan_validating_id();
  $pre_auth = !variable_get('user_email_verification', TRUE) && $validating_id != DRUPAL_AUTHENTICATED_RID;

  // Remove the pre-auth role from the user, unless they haven't been approved yet.
  if ($account->status) {
    if ($pre_auth) {
      db_query("DELETE FROM {users_roles} WHERE uid = %d AND rid = %d", $account->uid, $validating_id);

      // Since we're passing $account around to the update hook, remove
      // the pre-auth role from the roles array, and add in the auth user
      // role.
      $account->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
      unset($account->roles[$validating_id]);
    }
  }

  // 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)) {
    $edit = array();
    $account->logintoboggan_email_validated = TRUE;
    user_module_invoke('update', $edit, $account);
  }
}