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.

Redirect from restricted page?

Home Forums Community Forum Redirect from restricted page?

This topic contains 1 reply, has 2 voices. Last updated by  Alec Weekes 3 years, 11 months ago.

Topic Author Topic
Posted: Sunday Jan 20th, 2013 at 11:07 am #38415

Hi

I have a page that is restricted to Level 1 members (from the page I have selected ‘Require Level #1 (or higher)’ under Page Level Restriction. However, when I try and access this page when logged on as a level 0 user I just get a blank page instead of being redirected to the Membership Options page.

I think this did work at one stage, and wonder whether it is because I have changed the name of the Membership Options page. Where do I go to define the page I want the user to be redirected to check the URL is correct?

List Of Topic Replies

Viewing 1 replies (of 1 total)
Author Replies
Author Replies
Posted: Sunday Jan 20th, 2013 at 1:33 pm #38435

Hello Elizabeth,

We operate a similar function, where we have built an account dashboard for subscribed users to manage their accounts, such as resetting their password, viewing their current subscription level and downloading all their available products.

What we use a lot are the Conditional Else If statements to produce these systems.

Essentially what you’re going to want to do (I believe) is have an If Statement, that displays the content to paid members, and redirects everyone else away from the page.

<?php if (S2MEMBER_CURRENT_USER_ACCESS_LEVEL >= 1){ ?>

	Use this part of the code, to display anything you want to people who are paid subscribers of your site. 

<?php } else if(S2MEMBER_CURRENT_USER_ACCESS_LEVEL === 0){ ?>

    	<?php wp_redirect( 'http://www.example.com', 301 ); exit; ?>
    	# Use this to redirect anyone who is logged in, but not a paid member away from the page, to www.example.com #
    
<?php } else if(S2MEMBER_CURRENT_USER_ACCESS_LEVEL === -1){ ?>

    	<?php wp_redirect( 'http://www.example.com', 301 ); exit; ?>
    	# Use this to redirect anyone who is not logged in away from the page, to www.example.com #
    	
<?php } ?>
  • This reply was modified 3 years, 11 months ago by  Alec Weekes.
Viewing 1 replies (of 1 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.