• Resolved Jayc

    (@jaycgryder)


    So when I use the default autogenerated TML logout URL the page changes and loads a question page
    Page Title: Something went wrong
    You are attempting to log out of My Site
    Do you really want to log out?
    The words log out then has this URL
    https://mydomainname/logout/?redirect_to=https%3A%2F%2Fmydomainame%252&_wpnonce=4098333fb9

    I do not want this “horrible confirmation screen”
    How can I have it go straight to logout and end up on the main home page again?
    I have searched the support forum and none of the suggestions I have found worked…

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Jayc

    (@jaycgryder)

    I have found a method of disabling the confirmation. Am detailing the steps here for others in a similar problem.
    The TML logout URL is https://mydomainname/logout
    There is no page called logout.

    The following code disables the confirmation & was originally found at this URL
    https://wordpress.stackexchange.com/questions/67336/how-to-log-out-without-confirmation-do-you-really-want-to-log-out

    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'] : 'url-you-want-to-redirect';
            $location = str_replace('&', '&', wp_logout_url($redirect_to));
            header("Location: $location");
            die;
        }
    }
    

    Replace ‘url-you-want-to-redirect’ with the URL you want to redirect after logout.

    Add it in your functions.php

    Plugin Author Jeff Farthing

    (@jfarthing84)

    This could be a caching issue. Ask your hosting provider to exclude TML’s paths from the cache.

    /login
    /logout
    /register
    /lostpassword
    /resetpass

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Logout Forces Confirmation Page’ is closed to new replies.