latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Quick help! Bypassing restrictions…

Home Forums Community Forum Quick help! Bypassing restrictions…

This topic contains 8 replies, has 3 voices. Last updated by  John Ashcroft 3 years, 9 months ago.

Topic Author Topic
Posted: Thursday Mar 28th, 2013 at 3:54 pm #45991

Hey there – sorry to be flagging in the forum, but we’ve got a soft launch for tomorrow and we’re trying to — of course – deal with last minute client changes.

We’ve got a few uri restrictions and want to be able to allow the client to set restrictions per post; locally on my dev set up I just noticed that restrictions are not enforced because I had not set up a Membership Options Page — I had written code for a more ‘soft landing’ approach — when going to restricted content I was going to display partial content and a prompt to become a member.

On the LIVE machine of course restrictions are enforced, so non-members are being brought over to the membership options page BEFORE even getting to the protected post / soft landing display.

Is there anyway I can continue to allow them to set restrictions per post but bypass the built in enforcing? I know, that seems to be taking down all the strong walls built by s2member, but the code *is* in place to deal with hiding protected content…

List Of Topic Replies

Viewing 8 replies - 1 through 8 (of 8 total)
Author Replies
Author Replies
Posted: Thursday Mar 28th, 2013 at 5:04 pm #45998

I’m starting to think Bruce doesn’t love me :(

Posted: Thursday Mar 28th, 2013 at 9:25 pm #46012

Nobody? Even bought pro?

Posted: Friday Mar 29th, 2013 at 10:04 am #46059

Hi Garry.

Is there anyway I can continue to allow them to set restrictions per post but bypass the built in enforcing?

If you mean the Access Restrictions that protect the whole page, no, those will always redirect to the Membership Options Page when the user doesn’t have enough access to the URL he’s trying to load. [hilite path]Dashboard -› s2Member® -› Restriction Options[/hilite]

The only way to not have those redirections is not restricting the whole page, and instead protecting the content using conditionals. [hilite path]Dashboard -› s2Member® -› API / Scripting -› Conditionals[/hilite]

If you want to apply the condition to every post or page, you’d have to add it to the template instead of each individual post.

I hope that soft launch goes as well as possible. :)

Posted: Friday Mar 29th, 2013 at 10:50 am #46064

Thanks – getting there – but actually thought I’d respond as I did find a way.

Added a filter in s2-hacks.php in mu-plugins and all it does is return true:

add_filter(“ws_plugin__s2member_check_post_level_access_excluded”, “__return_true”);

So it’s bypassing any sort of restrictions. Then I’ve got code in the single checking:

function check_if_premium_content($postID){
		$found = false;		
		for($n=0; $n<=2; $n++){
			$p = "level".$n;
			$target = array_unique(preg_split("/[\r\n\t\s;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"][$p."_posts"]));
			if(in_array($postID, $target)){
				$found = $p;
			}
		}

		return $found;
	}

Which I took a bit from your plugin (the select on the post) — now I’m just checking for the postid in the post access, not caring about page or anything.

I can check as a boolean or check on a level. Once I get whether or not it’s protected, I can then check if the current user is logged in and has that level. Just putting it out there in case anyone else wants to know.

By the way – I’m surprised there’s no real built in function to just check the current posts level / protected; you check from the user side (user_can_access) and you have shortcodes/code for displaying differing content to levels, but no quick check for the current content’s level. Would be a nice add.

Posted: Friday Mar 29th, 2013 at 12:47 pm #46072
John Ashcroft
Username: ja1nsa

Garry – 100%… I have looked all over for this BASIC fix.

I say a fix as I deem it an essential. I mean you go to a webpage and want to view content before deciding to register, even more so before paying to register … so what is the point of S2 ???

If you do a fix, please advise. If I am logged in as Admin then “normal” behaviour is experienced. i.e. go to site, browse away, select page “Register HERE” and register if I want to. If I am job public and not signed in I go straight to register page and spoils the whole experience.

I am going to ask for a refund till this is fixed. Shame as the product looks good.

Posted: Friday Mar 29th, 2013 at 12:51 pm #46073

John – agree about the admin login – I work around that by using two browsers.

In my opinion I’ve got it working exactly the way I want it – it’s all good.

You can also do this easily by the custom capabilities if you’re a programmer – I just didn’t want to go down that route here as I’ve got others setting the posts.

I worked on a site where I was creating bundles to be purchased – you could either purchase a single title or that month’s group of video titles. I just created two buttons for every post – one that would save as a capability ‘single_(postID)’ and the other would get the post date of the post, and would allow purchasing of month_yyyymm — so when a person is logged in I just check to see if a) they have that months capability or b) that single capability. Works great.

Posted: Friday Mar 29th, 2013 at 2:23 pm #46078
John Ashcroft
Username: ja1nsa

Thanks Gary, but I ain’t no programmer and I just want a product to work when I buy it. Granted it probably doesn’t explicitly state it can do what I want, but I thought it a basic requirement. Ah well, lets see if I get an official response, though I have seen about 20 threads with the same issue and non were sorted.

Keep Well!
John.

Posted: Friday Mar 29th, 2013 at 2:53 pm #46081
John Ashcroft
Username: ja1nsa

Darn – I think I solved it!!

Download plug in called “Page Links to” and at the bottom of the Membership Options screen I entered the website URL again http://www.mytradesman.co.za it worked … I still get the spagetti in the URL after going to the main web page, but it re-directs to what is the original home page :)

Now to solve another couple of issues with this paid plugin :) – actually I like it, just needs a couple tweaks :)

Viewing 8 replies - 1 through 8 (of 8 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.