You are here

function _logintoboggan_user_roles_alter in LoginToboggan 7

Same name and namespace in other branches
  1. 5 logintoboggan.module \_logintoboggan_user_roles_alter()
  2. 6 logintoboggan.module \_logintoboggan_user_roles_alter()

Alter user roles for loaded user account.

If user is not an anonymous user, and the user has the pre-auth role, and the pre-auth role isn't also the auth role, then unset the auth role for this user--they haven't validated yet.

This alteration is required because sess_read() and user_load() automatically set the authenticated user role for all non-anonymous users (see http://drupal.org/node/92361).

Parameters

&$account: User account to have roles adjusted.

2 calls to _logintoboggan_user_roles_alter()
logintoboggan_boot in ./logintoboggan.module
Implement hook_menu_get_item_alter()
logintoboggan_user_load in ./logintoboggan.module
Implement hook_user_load().

File

./logintoboggan.module, line 640
LoginToboggan module

Code

function _logintoboggan_user_roles_alter($account) {
  $id = logintoboggan_validating_id();
  $in_pre_auth_role = in_array($id, array_keys($account->roles));
  if ($account->uid && $in_pre_auth_role) {
    if ($id != DRUPAL_AUTHENTICATED_RID) {
      unset($account->roles[DRUPAL_AUTHENTICATED_RID]);

      // Reset the permissions cache.
      drupal_static_reset('user_access');
    }
  }
}