You are here

function devel_switch_user in Devel 6

Same name and namespace in other branches
  1. 5 devel.module \devel_switch_user()
  2. 7 devel.module \devel_switch_user()

Switch from original user to another user and back.

Note: taken from mailhandler.module.

Note: You first need to run devel_switch_user without argument to store the current user. Call devel_switch_user without argument to set the user back to the original user.

Parameters

$name The username to switch to.:

1 string reference to 'devel_switch_user'
devel_menu in ./devel.module
Implementation of hook_menu().

File

./devel.module, line 1474

Code

function devel_switch_user($name = NULL) {
  global $user;
  static $orig_user = array();
  if (isset($name)) {
    $user = user_load(array(
      'name' => $name,
    ));
  }
  elseif (count($orig_user)) {
    $user = array_shift($orig_user);
    array_unshift($orig_user, $user);
  }
  else {
    $orig_user[] = $user;
  }
  drupal_goto();
}