Overide page restrictions rules to actually display restricted page instead redirect

Hello,

I have website with few user levels settings, and for now access to custom post types or taxonomies is restricted by user level, like free users, paid, vip, lifetime. If anyone without required level tries to access restricted page - it redirects user to payment form.

What I’m working right now is to actually open those restricted pages for even not logged in users, and then restricts content by theme code. I have no problem with theme code, cause I already found s2member functions to determine user’s level and it’s access for this page (if it is restricted), but the problem is that this code won’t work, cause users not allowed to see a page as a whole will be force redirected. I need everyone to be able to see a page, but the content itself will be different for allowed and not allowed users.

Is it possible to still use user levels, and page restrictions for them - while disabling blocking a page for not allowed users? I don’t want to disable s2member for specific pages or even cpt as a whole, cause then I won’t be able to determine by s2member functions if this user is actually allowed to see whole page content. Also I can’t use shortcodes to hide part of the content.

Any hints?

You could stop protecting pages and use [s2If] conditional tags instead to protect specific passages of content.

But if you are going to be doing this a lot, I doubt whether s2Member is really the most suitable plugin for you.

I already found that conditional tags solution, but as I mentioned, it is not an option - cause I would have to use it a lot, on many pages, while in code I can write it once, and will work on all pages displayed by this specific template. Also I still need a way to determine which page is protected with which level access, so I can not resign on protecting pages.

There is no filter or action I can deregister to just disable redirect/blocking process?

Little update, I managed to find in file security.inc.php method security_gate, which for example for posts runs c_ws_plugin__s2member_posts::check_post_level_access() method.

Then with this line:
$excluded = apply_filters('ws_plugin__s2member_check_post_level_access_excluded', FALSE, get_defined_vars());

I can filter $excluded value to be true whenever I want, cause the whole redirect method c_ws_plugin__s2member_mo_page::wp_redirect_w_mop_vars runs only if(!$excluded ...

I also already checked that is_post_permitted_by_s2member() function works fine and I can still use it to determine access restrictions.

So it should fit my needs. Anyone knows better solution?

I posted about using a filter here: Restrict all pages except