• Resolved joho68

    (@joho68)


    Scenario #1

    User goes to protected content URL like mysite.com/members/coolstuff. Either directly by pasting an URL or clicking on a link somewhere. The user is not logged in. I would like this to automatically re-direct to the login screen. How do I accomplish that?

    Scenario #2

    The user goes to the login screen, either by clicking a menu item or by pasting an URL into the browser. The user is already logged in when doing so. I would have expected the user to be re-directed to mysite.com/members/coolstuff since they’re already logged in, but it simply shows something similar to the login screen but instead given the choices of editing the profile and/or logging out. How do I make it automatically re-direct to the protected content if the user is already logged in.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support mbrsolution

    (@mbrsolution)

    Hi,

    Scenario #1

    Can you provide more information. I want to make sure I understand you correctly.

    Scenario #2

    Check the following documentation. Let me know if this helps you.

    https://simple-membership-plugin.com/configure-login-redirection-members/

    Thank you

    @mbrsolution With respect to scenario #1: I think, the OP means, that the user should be redirected to login widget/page without showing ‘This content is protected… you have to log in…’
    I were interested in a solution for that, too.
    Thanks

    Thread Starter joho68

    (@joho68)

    Well, I’ve solved these now with a rather simple fix in functions.php. It does not affect other functionality of the plugin, though I would consider it a “quick hack” ??

    Plugin Support mbrsolution

    (@mbrsolution)

    @joho68, that is great news. If you don’t mind can you share your solution to help others who might run into the same issue.

    Thank you

    Thread Starter joho68

    (@joho68)

    I won’t presume to know your code better, but my “quick hack” basically does this in functions.php:

    • Add hook to ‘wp’ action
    • Check if SWPM is an active plugin
    • Check if the requested URL is present in an array that the user has to maintain/modify
    • If the URL matches, and we’re not logged in, re-direct to login page

    It fetches the ‘login-page-url’ from your plugin’s settings. So, it truly is a “quick hack”, but it works.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Better re-directions’ is closed to new replies.