Logout without confirmation and SAME window on mobile

Question

I using this code to logout. It works except on mobile it opens a new window. How can I logout with confirmation and redirect to to the same window?

add_action('check_admin_referer', 'logout_without_confirm', 10, 2);
function logout_without_confirm($action, $result)
{
    /**
     * Allow logout without confirmation
     */
    if ($action == "log-out" && !isset($_GET['_wpnonce'])) {
        $redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : 'https://www.example.com';
        $location = str_replace('&', '&', wp_logout_url($redirect_to));
        header("Location: $location");
        die;
    }
}
0
, Pamela Ferguson 4 years 2019-02-19T19:37:59-05:00 0 Answers 88 views 0

Leave an answer

Browse
Browse