You are here

function mailhandler_user_switch in Mailhandler 6

Switch from original user to desired uid for content authoring.

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

Parameters

$uid The user ID to switch to:

Related topics

2 calls to mailhandler_user_switch()
mailhandler_node_process_message in ./mailhandler.module
mailhandler_switch_user in ./mailhandler.retrieve.inc
(DEPRECATED) Switch from original user to mail submision user and back.

File

./mailhandler.module, line 1307
Mailhandler module code.

Code

function mailhandler_user_switch($uid = NULL) {
  global $user;
  static $orig_user = array();
  if (isset($uid)) {
    session_save_session(FALSE);
    $user = user_load(array(
      'uid' => $uid,
    ));
  }
  else {
    if (count($orig_user)) {
      $user = array_shift($orig_user);
      session_save_session(TRUE);
      array_unshift($orig_user, $user);
    }
    else {
      $orig_user[] = $user;
    }
  }
}