Forums

Logout redirect problem (5 posts)

  1. marcelle42
    Member
    Posted 8 months ago #

    Hi,

    I'm working with a multisite installation, and every time a user logs out, they're redirected back to the primary homepage. So, if our primary domain is http://example.com, and I'm on http://subsite.example.com/wp-admin, and logout, I end up at http://example.com. I'd prefer to redirect users to the homepage of their own site (http://subsite.example.com), but I can't seem to find a way to make that happen. Suggestions, please? I'm mostly a theme developer, so this is a little over my head.

    Thanks!

  2. marcelle42
    Member
    Posted 8 months ago #

    Thanks for the quick reply! I'm trying to change it from the admin section (at least for now), so I tried the suggestion in the stack exchange link. I added

    add_filter('logout_url', 'logout_redirect'); 
    
    function logout_redirect($logout_url, $redirect) {
    return site_url();
    } // function

    to my functions.php file. And it certainly redirects to the subsite. But it no longer logs out -- the logout link itself in the Dashboard is just http://subsite.example.com, without any logout steps.

    I don't quite understand the Apache mod_rewrite stuff, or what I'm meant to do with return apply_filters('logout_url', $logout_url, $redirect);

  3. Yeah, you have to pass wp-login.php?action=logout&_wpnonce=[nonce]&redirect... I think.

    It'll need some playing.

  4. marcelle42
    Member
    Posted 8 months ago #

    Thanks. I've tried:

    add_filter('logout_url', 'logout_redirect'); 
    
    function logout_redirect($logout_url, $redirect) {
    return $logout_url."&redirect=".site_url();
    }

    and while the logout URL looks ok (http://subsite.example.com/wp-login.php?action=logout&_wpnonce=nonce&redirect=http://subsite.example.com), I still end up on http://example.com after clicking the logout link. Which is just baffling to me... shouldn't it redirect to the value of the redirect GET variable?

Reply

You must log in to post.

About this Topic

Tags

No tags yet.