How to redirect to same page after logout?

Discussion in 'aMember Pro v.4' started by primesitemm, Nov 19, 2012.

  1. primesitemm

    primesitemm New Member

    Joined:
    Oct 12, 2009
    Messages:
    19
    How to redirect to same page after logout?

    I see in aMember admin you can specify what page to redirect to after logout:
    http://v4.amember.com/docs/Setup/Login_Page#Login_Page_Options

    But if you leave it blank it will redirect to homepage.

    What if you don't want to redirect at all and just want the user to remain on the same page? How to do this?

    Thanks!
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,435
    Nothing checkbox. I think you would need custom coding, possibly in the site.inc.php file.

    David
  3. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    You can specify redirect url in query variables.
    For example:
    /amember/login?amember_redirect_url=/url/where/user/should/be/redirected/after/login
    The same format applies to logout script.
  4. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,435
    I think that he'd want it dynamically generated though within the logout link.

    David
  5. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    Actually my example should cover this situation. For example if content is PHP, you can place current page url in logout link:
    PHP:
    <a href='/amember/logout?amember_redirect_url=<?php echo urlencode($_SERVER['REQUEST_URI']);?>'>Logout</a>
  6. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,435
    What if you are using the wordpress plugin?

    David
  7. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    The same code should work inside wordpress theme files.
  8. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,435
    But what about the amember sidebar?

    David
  9. primesitemm

    primesitemm New Member

    Joined:
    Oct 12, 2009
    Messages:
    19
    Is it possible to setup the Logout URL with the same option (Last available URL) as the "Redirect after Login" in aMember admin?

    See screenshot:
    http://awesomescreenshot.com/0e1ngqd64

    Any plans for this in the next aMember update?
  10. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    Well I don't think that redirecting user to protected url will make any sense.
    What can be done is new option in Logout settings, somethink like : redirect user to the page where logout link was clicked.
    Then aMember could check referrer and redirect user back.
    http://bt.amember.com/issues/1014
  11. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    Btw, I believe this will cover logout link in sidebar as well.

Share This Page