Page 1 of 1

Restrict lower level shortcodes

PostPosted: January 31st, 2012, 4:32 pm
by moymoy_101890
I would like to seek help. I am a beginner here in the s2member plugin. I dont know if this is possible but i would like to know if i can set a page that can be seen by public and cant be seen by members of any level. your help would be really appreciated.

Re: Restrict lower level shortcodes

PostPosted: January 31st, 2012, 6:43 pm
by Raam Dev
You could do this by inserting some PHP code into the page to check if the user is logged in (see WP Admin -> s2Member -> API/Scripting -> Advanced/PHP Conditionals for more info).

If they are logged in, don't show the content. If they are not logged in, show the content. You will need to install and activate the Exec-PHP Plugin before you can use this code on a post/page:

Code: Select all
<?php if(is_user_logged_in()){ ?>
    Content for anyone that is logged in, regardless of their Membership Level.
<?php } else { ?>
    Some public content.
<?php } ?>

Re: Restrict lower level shortcodes

PostPosted: February 1st, 2012, 6:42 am
by moymoy_101890
can this actually hide the the page? coz i use the login page for public use only so i need to hide it when im logged in. thanks for the tip sir.

Re: Restrict lower level shortcodes

PostPosted: February 1st, 2012, 2:25 pm
by moymoy_101890
and by the way the login page is located in the nav bar.

Re: Restrict lower level shortcodes

PostPosted: February 2nd, 2012, 2:05 pm
by Raam Dev
In that case you can edit your theme template where the nav menu is generated (probably in header.php) and do something like this:

Code: Select all
<?php if(is_user_logged_in()) { ?>
Welcome!
<?php } else { ?>
<a href="/login/">Login</a>
<?php } ?>