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.

Global array for protected specific post/page

Home Forums Community Forum Global array for protected specific post/page

This topic contains 2 replies, has 2 voices. Last updated by  Neil Haywood 3 years, 10 months ago.

Topic Author Topic
Posted: Monday Feb 25th, 2013 at 7:20 pm #43192

Do you have a global array for pages which are protected by s2member just through the Specific Posts/Pages access restrictions page?

Maybe if I explain our issue you may be able to help with the best solution to the issue.

We offer membership to our site and use the level1 access to protect any member content. This works great.

We also offer services and use s2Member to protect specific pages dedicated to that service. If a user tries to access these pages while they are not logged in they are redirected to the Members Options page. We would like to offer a different message to the user if they are trying to access a specific page instead of member content. How would you best code the logic for this kind of check on the members options page.

--user is a member--
	some code to display member options, upgrades, cancellations etc
--user is not a member--
	----user has tried to access a member protected page----
		some code to display member sign up with member info
	----user has tried to access a specific page protected by s2Member (ie a service page)----
		some code to advise the user to retry the link contained in email or to sign up to the service again if service access has expired.

Hope this makes sense. We didn’t want to list every protected specific page ID in our logic checks as we have a few.

We are comfortable with php code so feel free to give a detailed example if needed.

Thanks for your assistance!

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Thursday Feb 28th, 2013 at 2:13 am #43375
Bruce
Username: Bruce
Staff Member

Thank you for your inquiry. We appreciate your patience.

Do you have a global array for pages which are protected by s2member just through the Specific Posts/Pages access restrictions page?

I would recommend using the is_post_protected_by_s2member() function here. You can find info on how this function works here:

http://www.s2member.com/codex/stable/s2member/api_functions/package-functions/#src_doc_is_post_protected_by_s2member()

We also offer services and use s2Member to protect specific pages dedicated to that service. If a user tries to access these pages while they are not logged in they are redirected to the Members Options page. We would like to offer a different message to the user if they are trying to access a specific page instead of member content. How would you best code the logic for this kind of check on the members options page.

s2Member passes a number of variables to the Membership Options Page when a User is redirected. You can use these variables within your Membership Options Page with a PHP Execution Plugin to display dynamic content based on these variables.

See: Dashboard -› s2Member® -› API / Scripting -› Membership Options Page Variables (MOP Vars)
See Also: Knowledge Base » ezPHP Plugin for WordPress®

Based on your requirements above, I believe that you should have something like this on your Membership Options Page:

<?php if(is_user_logged_in()) /* Current User is logged in? */ { ?>
	some code to display member options, upgrades, cancellations etc
<?php } else { 
	if(isset($_REQUEST&#91;'_s2member_seeking'&#93;&#91;'sp'&#93;)) {
		// This is a Specific Post/Page Restriction redirect
	}
	
	elseif(isset($_REQUEST&#91;'_s2member_seeking'&#93;)) {
		// This is a general redirect
	}
} ?>

See: Dashboard -› s2Member® -› API / Scripting -› Advanced PHP Conditionals

Posted: Thursday Feb 28th, 2013 at 3:46 am #43384

Hi Bruce,

Thats perfect! Easy when you know how :-).

Cheers,

Neil.

Viewing 2 replies - 1 through 2 (of 2 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.