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.

Restict all pages except specified

Home Forums Community Forum Restict all pages except specified

Tagged: ,

This topic contains 5 replies, has 2 voices. Last updated by  Raam Dev 4 years, 5 months ago.

Topic Author Topic
Posted: Tuesday Jul 10th, 2012 at 10:50 am #18807

I’ve seen a couple of other posts about this in the forums but without any response.

Is there a way to have all pages restricted by default then specify the ones you want to be publicly viewable?
So kinda the opposite of the current system.

My reason for doing this is that I have multiple membership options pages for different nationalities. These are the only pages that need public access.

Or is there maybe some other way of achieving what I’m trying to achieve?

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Wednesday Jul 11th, 2012 at 2:19 am #18875
Raam Dev
Username: Raam
Staff Member

Hi Christian,

On the Page Access Restrictions (Dashboard -› s2Member® -› Restriction Options -› Page Access Restrictions), you can type all to restrict all pages to a specific level.

Posted: Wednesday Jul 11th, 2012 at 6:50 am #18906

I’ve done that. The problem is that I want to allow access to just a couple of pages. I need multiple membership options pages. Obviously one of them is made public by default but I can’t make the others public.
I’d really rather not have to restrict access to each of my sites pages individually when I only want to give access to 3 or 4 pages.

Posted: Thursday Jul 12th, 2012 at 2:13 am #18986
Raam Dev
Username: Raam
Staff Member

Christian,

In that case I recommend removing all from your Page Restrictions and then editing your theme’s page.php file and modifying it so that it checks if the current visitor is logged in OR if the current page matches the page ID that everyone should see. For example:

<?php if (S2MEMBER_CURRENT_USER_IS_LOGGED_IN || get_the_ID() == 532 || get_the_ID() == 253){ ?>
	Code to display page for logged in members OR to anyone if the page id = 532 OR to anyone if the page id = 253
<?php } else { ?>
	If user is not logged in AND the page id is not 532 or 253, then redirect somewhere else:
	<script type="text/javascript">
	<!--
	window.location = "http://example.com/membership-options-page/";
	//-->
	</script>
<?php } ?>

Please see example #7 in Dashboard -› s2Member® -› API / Scripting -› Advanced PHP Conditionals.

Posted: Thursday Jul 12th, 2012 at 12:07 pm #19046

I’ll give that a try.

Thanks a lot!

Posted: Friday Jul 13th, 2012 at 1:26 am #19117
Raam Dev
Username: Raam
Staff Member

Glad to help! :)

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