• Resolved SWATH

    (@swath)


    I’m really new to this so I am having trouble figuring this out. I want a logged in user to be able to press the logout button in the Nav bar no matter what page he is on, get logged off, then remain on whatever the current page is and not be taken anywhere.

    https://wordpress.org/plugins/peters-login-redirect/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Chris Dillon

    (@cdillon27)

    Sorry, disregard. Wrong post.

    Though I am looking at your issue 🙂

    Chris Dillon

    (@cdillon27)

    The plugin does not have that option but we can create a custom variable using a filter.

    Add this to your theme’s functions.php:

    function stay_on_current_page( $bool, $variable, $user )
    {
      if( 'current_page' == $variable )
      {
        return $_SERVER['HTTP_REFERER'];
      }
    }
    add_filter( 'rul_replace_variable', 'stay_on_current_page', 10, 3 );

    Then use this in the logout settings:

    [variable]current_page[/variable]

    Chris Dillon

    (@cdillon27)

    I was mistaken. The plugin does have that option. Just use

    [variable]http_referer[/variable]

    in the logout settings.

    Thread Starter SWATH

    (@swath)

    Great! Thanks a lot Chris, that did the trick.

    Thread Starter SWATH

    (@swath)

    Excellent! That worked too so I can just removed that snippet of code.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to redirect back to current page after logout’ is closed to new replies.