You are here

function _masquerade_user_load in Masquerade 7

Same name and namespace in other branches
  1. 6 masquerade.module \_masquerade_user_load()

Wrapper around user_load() to allow the loading of anonymous users.

Parameters

$username: The username of the user you wish to load (i.e. $user->name). To load the anonymous user, pass the value of the 'anonymous' variable.

Return value

A fully-loaded $user object upon successful user load or FALSE if user cannot be loaded.

8 calls to _masquerade_user_load()
masquerade_admin_settings in ./masquerade.module
Admin settings form.
masquerade_admin_settings_validate in ./masquerade.module
masquerade_block_1_submit in ./masquerade.module
Masquerade block form submission.
masquerade_block_1_validate in ./masquerade.module
Masquerade block form validation.
masquerade_menu in ./masquerade.module
Implements hook_menu().

... See full list

File

./masquerade.module, line 350
The masquerade module allows administrators to masquerade as other user.

Code

function _masquerade_user_load($username) {
  $account = FALSE;
  if (!empty($username)) {
    $anon = variable_get('anonymous', t('Anonymous'));
    $account = user_load_by_name($username == $anon ? '' : $username);
    if (isset($account->uid) && empty($account->uid)) {

      // Anonymous user should have a name.
      $account->name = $anon;
    }
  }
  return $account;
}