Redirect members based on membership level

We have several membership levels for our site and we would like members be directed to a different page when they login based on their membership level. What would be the best way to handle this?

  • shawn_johnston

    I'm not exactly clear on how the shortcodes work. Will this work everytime the user logins or do they need to be placed somewhere?

    Also our client provided feedback and I may have misunderstood their request. We have a paid membership and a limited free membership. The client actually wants there to be specific redirections after they have registered and not logged in, sorry about that.

    It seems that as a free member they are directed to the welcome page and then need to log in but if the user pays for the better membership once they have been redirected from the payment gateway back to the site they are sent to the same welcome page with a login form. We would like the paid members to be directed to members only section instead.

    Thanks

  • ghc

    Each level has a shortcode that "can be used to wrap content that you only want to be seen by members on this level e.g. [levelshortcode] protected content [/levelshortcode], use the [not-levelshortcode] shortcodes to wrap content that should be visible to people not on a particular level."

    In the case of my previous example:

    [level-gold-1-level-2]
    <script language=”javascript” type=”text/javascript”>
    window.location.href=”/gold-membership";
    </script>
    [/level-gold-1-level-2]

    if a user of level "gold 1 level 2" (which generates the shortcode [level-gold-1-level-2]) visits the page that contains the above code, the <script> would be written into the html and executed by the browser. If anyone not of the aforementioned level views the page, the script will be "protected", or not shown.

  • ghc

    In my experiments so far, registering logs you in. Is there a setting that prevents that? A confirmation email perhaps?

    If both paid and unpaid members are landing on the same page, you could use my previous example to target the initial level of the paid subscription and use the javascript redirect I mentioned previously.

    But you might want something a little cleaner, like PHP.

    Here's a redirect in PHP (from WikiPedia):

    <?php header('HTTP/1.1 301 Moved Permanently');
    header('Location: http://www.example.com/');
    exit(); ?>

    I don't yet know if you can easily put PHP in a level shortcode, or if that PHP redirect will even work in the middle of a page like this would end up.

  • aecnu

    Greetings Shawn and ghc,

    GHC's recommendations are great and thank you for that input of course.

    Redirection can be done hard coding the gateway files, in which once hard coded into them I would recommend copying the gateway folder so that it can be replaced after updates.

    An example of coding this would be added to the PayPal form/button coding in this case something like:

    <input type="hidden" name="return" value="http://yourmembershipdomain.com/paidmember.htm">

    Thank you for being WPMU Dev Community Members!

    Cheers, Joe

  • aecnu

    Greetings Shawn and ghc,

    Thank you again for your audience, I am laughing at myself for missing the easy and obvious solution making this harder then it should be .... lol

    Screen shot below which clearly states in the admin dashboard --> Membership --> Options --> Membership Pages tab --> Registration Completed section:

    When a user has signed up for membership and completed any payments required, they will be redirected to this page.

    You should include a welcome message on this page and some details on what to do next.

    Cheers, Joe

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.