Example #1
0
        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;
    }
}
if (!function_exists('current_user_switched')) {
    /**
     * Helper function. Did the current user switch into their account?
     *
     * @return bool|WP_User False if the user isn't logged in or they didn't switch in; old user object (which evaluates to
     *                      true) if the user switched into the current user account.
     */
    function current_user_switched()
    {
        if (!is_user_logged_in()) {
            return false;
        }
        return user_switching::get_old_user();
    }
}
$GLOBALS['user_switching'] = user_switching::get_instance();