Request a Quote
Customer Focused
Web Services

Hide Logout Confirmation Popup

June 15, 2022
Code Category:

Normally, when you hit the logout link in WP, you get sent to a warning screen where you have to hit another link to actually log out. Annoying.

add_action('check_admin_referer', 'fotan_logout_without_confirm', 10, 2);
function fotan_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'] : get_permalink( wp_logout_url() );
        $location = str_replace('&', '&', wp_logout_url($redirect_to));
        header("Location: $location");
        die;
    }
}
Give us a call (541) 784-5711

Start a converstation

©2024 Fotan Web Design