CCAP - redirection when CCAP check fails - how do I?

My situation
I want to use CCAP to restrict who can access a page based up a CCAP. I was going to code like the below If/else, but my page is built with elements and a Gravity Form. So it is hard to place the content in the middle of the code.

I figured next I would go to the side bar and put in the CCAP restriction - it works. However when a user comes in with the wrong CCAP there is no error message the user suddenly ends up on my Welcome page. It is confusing. What I would like to do is have a different page come up stating they don’t have the membership level to access this area. After an hour of searching and reading and I can’t find how to do this.

Lastly, I am not a code jockey, business owner trying build my site and save $. So I can do something go work but my skills are not deep :slight_smile:

[s2If current_user_can(access_s2member_ccap_Project_Limited)]
Content for members with the Custom Capability: music
[else]
Access is restricted to Project Owners with Limited membership.
[/s2If]

forgot to mention I have Pro

Yes, that’s the behaviour of S2 - I have that on my site too. I believe you can put a shortcode conditional on the page above the restricted content. In other words S2 will let you protect part of the page and leave the rest for public consumption. That way you could put a message like ’ not seeing this great product and want to see more? click here to purchase’. That would go above the protected content.

BUT why are they able to come in without the right protections? What you need to do is set up your site pages so that coming in from the member’s area, they can only click on their products, and if they click on the wrong one, they go to the sales page. :slight_smile:

Hi Mark.

when a user comes in with the wrong CCAP there is no error message the user suddenly ends up on my Welcome page.

They’d be sent to the Membership Options Page, including some variables in the URL that you can then use to customize the message they get there. WP Admin > s2Member > API / Scripting > Membership Options Page Vars https://s2member.com/kb-article/s2mop-shortcode/

I was going to code like the below If/else, but my page is built with elements and a Gravity Form. So it is hard to place the content in the middle of the code.

Why is it hard? I’m not familiar with them. Do those not let you use shortcodes?

Hi Cristian, I was able to figure out how to make this work. Not being a coder or a lot of WP experience I was overlooking the obvious solution. Everything I was dealing with was graphical drag & drop boxes and I could figure out how to use text / code.

When I change the view of my editor to classic where the raw text is displayed I was easily able to insert my S2 If Else statement. Hopefully this thread will save some other rookie some pain :smile:

1 Like