function masquerade_perform_masquerade
Search API
7.x masquerade.module | masquerade_perform_masquerade() |
6.x masquerade.module | masquerade_perform_masquerade() |
Actually perform the switching of users to the selected user.
File
- modules/
masquerade/ masquerade.module, line 55 - The masquerade module, which allows admin users to impersonate other users.
Code
function masquerade_perform_masquerade() {
global $user;
$user_id = intval($_REQUEST ["user_id"]);
// Do not allow user_id 1
if ($user_id === 1) {
fp_add_message(t("Admin user is not allowed to be selected for masquerade."), "error");
fp_goto("<front>");
return;
}
// Set up a new $account object.
$account = new stdClass();
$account = fp_load_user($user_id);
// Okay, let's look for all the modules who have implimented hook_user_login
$modules = modules_implement_hook("user_login");
foreach ($modules as $module) {
call_user_func_array($module . '_user_login', array(&$account));
}
// Set the $account to the SESSION.
$_SESSION ["fp_user_object"] = $account;
watchdog("masquerade", "@user is now masquerading as @newuser. New CWID: @cwid", array("@user" => "$user->name ($user->id)", "@newuser" => "$account->name ($account->id)", "@cwid" => $account->cwid));
$_SESSION ["masquerade_active"] = TRUE;
$_SESSION ["masquerade_original_user"] = $user;
fp_goto("<front>");
}