Bug: On logout shows WP login screen

Discussion in 'WordPress' started by CountRock, Mar 23, 2014.

  1. Have feature suggestions for the WordPress plugin? Post or vote here.
  1. CountRock

    CountRock New Member

    If we click the Log out button from the Admin menu bar (Not 100% what its called :p) it goes to this screen
    upload_2014-3-22_20-28-52.png

    It should ideally go to the home page.
     
  2. xfrocks

    xfrocks XenForo rocks!
    Staff Member

    I believe this is WordPress default behavior.
     
  3. CountRock

    CountRock New Member

    #3 CountRock, Mar 23, 2014
    Last edited: Mar 23, 2014
    Can the default behaviour be changed? ;)

    Edit: I got it. Add this in your functions.php file under your theme

    PHP:
    //Logout to home page custom code
    add_action('wp_logout',create_function('','wp_redirect(home_url());exit();'));
     
  4. CountRock

    CountRock New Member

    #4 CountRock, Mar 23, 2014
    Last edited: Mar 23, 2014
    Ok a bug report now
    The logout on WP side doesn't really work since it does not log the sure out from XF. So when you are redirected to home page you get logged in again.

    Ideally if you click logout on their XF or WP you should be logged out of both places. Since both my WP and XF are on the same domain they should be able to delete each other's cookie. Will report back if successful.

    Edit 1: PS: SSO = Single sign on should also include a Single Sign off! :D:p
    Edit 2: I am sure I can delete the cookie for either but it won't invalidate the session from the server side. This will require more thought. :eek:
     
  5. xfrocks

    xfrocks XenForo rocks!
    Staff Member

    Actually it does log out from XenForo. Makes sure you have latest version of the XenForo add-on.
     
    1. CountRock

      CountRock New Member

      CountRock @xfrocks I have the latest version installed. Do you think its because of the password protected directory it isn't working?

      upload_2014-3-23_9-13-13.png

      What happens now is that if I click the logout from the admin bar in WP it logs out and when the home page loads again it logs back in since it didn't logout from XF
       
  6. xfrocks

    xfrocks XenForo rocks!
    Staff Member

    1. CountRock

      CountRock New Member

      #8 CountRock, Mar 24, 2014
      Last edited: Mar 24, 2014
      CountRock @xfrocks I tried, you are correct if you logoff at WP it logs out in both places. However if you go to XF when log off in XF. It stays logged in WP.

      I have thought of a way to fix this also also perform another useful task :) Will update
       
    2. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @CountRock That's correct. If you login in both sites and logout from master first, the slave will not know that fact and keep you logged in.
       
  7. CountRock

    CountRock New Member

    #10 CountRock, Mar 26, 2014
    Last edited: Mar 26, 2014
    I got a work around for logout issue. Where you can log out of XF and WP from XF.

    I have installed a plugin in XF to redirect users on logout to the URL. The plugin's name
    Brivium - Redirect on Login/Logout
    Code:
    http://www.teamfiat.com/wp-login.php?action=logout
    Since WP has a nonce which prevents direct linking to the URL. you will have to edit and comment out the check_admin_referer line in wp-login.php
    PHP:
    case 'logout' :
        
    //check_admin_referer('log-out');
        
    wp_logout();
    And as stated about, add this in your functions.php file under your Wordpress theme

    PHP:
    //Logout to home page custom code
    add_action('wp_logout',create_function('','wp_redirect(home_url());exit();'));
    This kills 2 birds with the same stone. Since I wanted to redirect users to the WP anyway on logout!
     
    1. xfrocks

      xfrocks XenForo rocks!
      Staff Member

      xfrocks @CountRock That's a nice way to do it ;)
       
Loading...