Membership Options Page CONDITIONAL Redirect

Hello,

I’m wondering if it’s possible to supply a conditional redirect to “Membership Options” page based on the membership level or Custom Capabilities?

I want Member Type A (or CustomCapability) to be redirected to Membership Options Page 1.
I want Member Type B (or CustomCapability) to be redirected to Membership Options Page 2.

Thank you for your help!
Herc

See https://s2member.com/kb-article/automatically-redirecting-to-a-protected-page-after-login/

Hey Tim,

Thanks. I read that article, but it didn’t have any information about conditional redirects based on membership type or CustomCapability.

It was more about conditional redirect based on if logged in or not.

Not quite what I need.

It depends whether you want to redirect people to the target page before they log in or after they login.

This code ensures that if they login on the target page they will remain on the target page.

So, for example, if you already have customers segmented in your Newsletter Mailer (e.g. MailChimp) or CRM (e.g. Insigtly) then you can email them links that take them to the target page and this code ensures when they log in that they stay on that page.

You could also disable the S2Member login redirect and use a redirection plug-in like https://en-au.wordpress.org/plugins/redirection/

There are many paths to the outcome.

It would be easier for others to assist if you mapped out how users would get to where you want to get them…e.g.

  • You already know who they are pre-login and can redirect them via custom url before they hit the site
  • You already know who they are pre-login and can have a landing page that can redirect them to the appropriate target page when they access the page
  • You don’t know who they are pre-login BUT you can have a landing page that has a form that asks a question that is used to know which page to redirect them to
  • etc, etc

The way I’m using s2 is to allow free trial members to access certain parts of my membership site. When they try and access locked areas they are taken to my Membership Options page.

But I now want to take members to different offers based on the type of free membership they have.

So I can use CUSTOM CAPABILITY on their free trial sign up to segment them, and hoping to use custom capability tag to redirect them to the proper member options page when they try to access locked areas.

The login path already works the same for everyone, which is perfect.

Option 1: Put Javascript conditional redirects on the s2member membership page wrapped in S2member conditional shortcodes.

See https://www.w3schools.com/howto/howto_js_redirect_webpage.asp for the 1-line JS redirect.
See https://s2member.com/kb-article/s2if-simple-shortcode-conditionals/ for s2member conditional shortcodes

OPtion 2: Otherwise, the https://en-au.wordpress.org/plugins/redirection/ plug-in might do what you want. It can redirect on capability. Just remember to disable the S2Member custom login redirect if you have one.

I would use Option 1.

2 Likes

Bad ass…thank you

You are most welcome :slight_smile:

NOTE: If you haven’t used the S2Member shortcodes before, they can be nested. In combination you can create virtually any complex condition combination. I use it in most of my sites for different reasons (like conditional redirects and segmenting free / paid content on blog posts).

window.location.replace(‘http://w3c.com’);

Using replace() is better for javascript redirect , because it does not keep the originating page in the session history, meaning the user won’t get stuck in a never-ending back-button fiasco.