function _logintoboggan_user_roles_alter in LoginToboggan 6
Same name and namespace in other branches
- 5 logintoboggan.module \_logintoboggan_user_roles_alter()
- 7 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_init in ./
logintoboggan.module - Implementation of hook_init()
- logintoboggan_user in ./
logintoboggan.module - Implementation of hook_user().
File
- ./
logintoboggan.module, line 487 - 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. Since the only
// goal here is to reset the cache, create a
// temporary account object for uid 1 -- this
// results in no hits on the database.
$temp_account = new stdClass();
$temp_account->uid = 1;
user_access('', $temp_account, TRUE);
}
}
}