Ejemplo n.º 1
0
 /**
  * Switches off the current logged in user. This logs the current user out while retaining a cookie allowing them to log
  * straight back in using the 'Switch back to {user}' system.
  *
  * @return bool True on success, false on failure.
  */
 function switch_off_user()
 {
     if (!($old_user_id = get_current_user_id())) {
         return false;
     }
     user_switching_set_olduser_cookie($old_user_id);
     wp_clear_auth_cookie();
     wp_set_current_user(0);
     /**
      * Fires when a user switches off.
      *
      * @since 0.6.0
      *
      * @param int $old_user_id The ID of the user switching off.
      */
     do_action('switch_off_user', $old_user_id);
     return true;
 }
 /**
  * Switches off the current logged in user. This logs the current user out while retaining a cookie allowing them to log
  * straight back in using the 'Switch back to {user}' system.
  *
  * @return bool True on success, false on failure.
  */
 function switch_off_user()
 {
     if (!($old_user_id = get_current_user_id())) {
         return false;
     }
     user_switching_set_olduser_cookie($old_user_id);
     wp_clear_auth_cookie();
     wp_set_current_user(0);
     do_action('switch_off_user', $old_user_id);
     return true;
 }