WebsiteMembership redirect on logoff not working as expected

3 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: May 6, 2022   (RSS)

By daniel - May 5, 2022

Hi pgplast,

When logging off, the script first checks for the "HTTP_REFERER" which essentially means that it will always prefer to redirect the user back to the page they clicked the log off link from, unless they directly entered the URL into the browser address bar.

There are a few ways I can think of to handle this in your situation:

  1. On your internal pages, check to see if the user is logged in and if not, redirect them elsewhere, like this:
    <?php
      if (empty( $CURRENT_USER )) { websiteLogin_redirectToLogin(); }
    ?>​

    This also helps users from accidentally navigating to these pages while logged out. You can use redirectBrowserToURL() instead of websiteLogin_redirectToLogin() if you want to redirect to a specific page other than the login page.

  2. Set up your own logoff page that calls user_logoff(), instead of using _websiteLogin_logoff() or ?action=logoff. You can pass whatever URL you want the logged-out users to reach as a parameter to user_logoff().

Let me know if that helps, or if you have any other questions!

Thanks,

Daniel
Technical Lead
interactivetools.com

By pgplast - May 6, 2022

Thanks Daniel. Your solutions work, and I had already employed your "Plan B."

However, I was worried that I was overlooking something in the setup of the plugin that would take care of this scenario itself.

Thanks again for your prompt assist!