• Resolved Ross Wintle

    (@magicroundabout)


    Hi there,

    I’m using the latest version of both the plugin and WordPress. The logout redirect setting doesn’t work as I expected it to – it ONLY applies to using a logout link in the widget.

    I have a logout link in the header of my theme. It’s coded using echo wp_logout_url();, but it doesn’t obey the redirect setting in your plugin.

    Can I propose that you add in settings.php to the load_settings() method something like:

    
    add_filter('logout_redirect', function ( $redirect_to, $requested_redirect_to, $user ) {
                                    $logout_redirect_page = get_option('logout_redirect_page');
                                    return $logout_redirect_page ? get_permalink($logout_redirect_page) : $redirect_to;
    }, 10, 3);
    
    • This topic was modified 8 years, 4 months ago by Ross Wintle.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author aviplugins.com

    (@avimegladon)

    The logout_redirect filter is not added because it can cause conflict with other plugins. It will override other logout redirects if you have any.

    So it will be better if you add the code

    
    add_filter('logout_redirect', function ( $redirect_to, $requested_redirect_to, $user ) {
                                    $logout_redirect_page = get_option('logout_redirect_page');
                                    return $logout_redirect_page ? get_permalink($logout_redirect_page) : $redirect_to;
    }, 10, 3);
    

    in your functions.php or directly write logout code in your header

    
    wp_logout_url( home_url() );
    
    Thread Starter Ross Wintle

    (@magicroundabout)

    Thanks for the response. That’s kinda what I would expect to happen to be honest. If I install two plugins that both do redirect on logout then I’m probably doing something wrong. But sounds like you’ve had problems in the past.

    Perhaps having “always redirect logout” as an option would make this work for everyone?

    I’ve already added the code to my theme. Thanks for the tip though.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Logout redirect doesn’t work’ is closed to new replies.