• Resolved ace0930

    (@ace0930)


    I’m using this code for users to logout

    <a href="<?php echo wp_logout_url('/redirect/url/goes/here') ?>">Log out</a>

    But the problem is that it will first go to the login page, then only redirect to the specified URL. How to make it directly logout + redirect to the specified URL without going to the login page?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Jamie Blomerus

    (@jamieblomerus)

    It is kinda impossible unless you make the linked page call the wp_logout() function. My suggestion would be to make a GET argument that logs the user out and then add it to the end of the link.

    Jamie Blomerus

    (@jamieblomerus)

    I just made an quick example/POC:

    function logout_on_get_argument() {
        if(isset($_GET['logout'])) {
            wp_logout();
        }
    }
    
    add_action("init", "logout_on_get_argument");
    Thread Starter ace0930

    (@ace0930)

    Interesting, let me try.

    Jamie Blomerus

    (@jamieblomerus)

    Please update us on how it is going. And change the status to Resolved, if my answer worked.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Logout link without going to login page’ is closed to new replies.