PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Redirecting on Login and on Page restriction

s2Member Plugin. A Membership plugin for WordPress®.

Redirecting on Login and on Page restriction

Postby philipt18 » December 26th, 2011, 10:47 am

I have two related questions.

1) When a user logs in, can I redirect the user to a different page based on their level? i.e. Level 0 goes to one page, Level 1 goes to another page, etc.?

2) When a user accesses a page or post that they are not allowed to access, right now everyone for every page gets sent to the same explanation page (which must be public). Is there a way to specify for a page which explanatory page a user gets sent to? or sending users to different explanatory pages based on their level?

For example, let's say I have three tiers of users - non-logged in, logged-in free subscribers, and paid members. If some pages are only visible to people that are logged in, then it makes sense that the explanatory page would explain why you should register for the site, but if there is a page that is only accessible to members, and non-logged in users can't even see it normally, then it doesn't make sense to explain about registering for the site, but instead the page should explain why they should pay for the membership tier.

Even better, for some pages I'd like to be able to explain specifically why the user should register or pay for membership, i.e. I'd like to describe what is beneficial about that specific restricted resource.

Is there any way to do either of these? Thanks.
User avatar
philipt18
Experienced User
Experienced User
 
Posts: 50
Joined: December 1, 2011

Re: Redirecting on Login and on Page restriction

Postby Eduan » December 26th, 2011, 10:57 am

This is possible, yes.
Check this video on how to do that:
http://www.s2member.com/paypal-modifica ... ons-video/

You might also be interested in conditionals (mentioned in video), check under WP Admin -> s2Member -> API / Scripting -> Simple/Shortcode Conditionals.

Hope this helps. :)
Now officially accepting Professional s2Member installations along with Bruce C (a.k.a. Ace).

If you're interested in a Professional s2Member Installation, or a Custom Coding Job, you can send your request here.
User avatar
Eduan
Experienced User
Experienced User
 
Posts: 1154
Joined: August 27, 2011
Location: Taxco de Alarcón, Guerrero, México.

Re: Redirecting on Login and on Page restriction

Postby philipt18 » December 26th, 2011, 11:32 am

I need to watch more of the videos, but I see that you can set up different login pages by creating multiple pages with the level ID number in the slug. That can work, but I'd like to ask in the future if you could just offer a list of levels, and let me select from my pages which page to send the user to for each level. This is simpler, and easier to understand if multiple people are working on the site.

Also, where can I find out how to define what the user sees when they are rejected from a specific page? Thanks.
User avatar
philipt18
Experienced User
Experienced User
 
Posts: 50
Joined: December 1, 2011

Re: Redirecting on Login and on Page restriction

Postby Eduan » December 26th, 2011, 11:46 am

If they don't have access to a certain page they will then be re-directed to the Membership Options Page, where they will get different messages depending on the level, following the instructions on the video.

As I said before, the conditionals, I think are the best option in order to make it simple.

I hope this helps. :)
Now officially accepting Professional s2Member installations along with Bruce C (a.k.a. Ace).

If you're interested in a Professional s2Member Installation, or a Custom Coding Job, you can send your request here.
User avatar
Eduan
Experienced User
Experienced User
 
Posts: 1154
Joined: August 27, 2011
Location: Taxco de Alarcón, Guerrero, México.

Re: Redirecting on Login and on Page restriction

Postby Cristián Lávaque » December 27th, 2011, 5:04 am

Philip, you can use the Membership Options variables to customize the message based on what page the person tried to view without the right access. WP Admin -> s2Member -> API / Scripting -> Membership Options Page Variables

If you want to have different Login Welcome Pages based on the user's level, you could have a PHP conditional there that will redirect with JavaScript to the page for his level.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Redirecting on Login and on Page restriction

Postby philipt18 » December 27th, 2011, 6:23 am

That looks like what I need, but I'm trying to get my head around it. Am I redirecting the person to another page, or creating content on the Member Options page that is specific to people coming from a particular content type/page?

Also, is there a way to do thing like recognize all pages that are children of a specific page (so I don't have to return to this code and keep adding page IDs)?

In one example, I have a Resources Page which is viewable by everyone, but which links to a series of child pages which are mostly only available to registered users (level 0). When someone tries to access one of those child pages who is not logged in, I want to explain what the resource pages are, and how to gain access to them. Essentially this is the 'user is not registered' page. Theoretically I might have a few of these pages for other areas of the site that are restricted.

In another example, I have a page with children that is only accessible to paid members (level 1). With those pages, I want to show a different explanation about membership and its benefits, and how to become a member. Essentially, this is the 'user is not a member' page.

So back to my question above, am I redirecting to multiple pages, or creating multiple sections on the Member Options page? An example or two would be greatly appreciated. Thanks.
User avatar
philipt18
Experienced User
Experienced User
 
Posts: 50
Joined: December 1, 2011

Re: Redirecting on Login and on Page restriction

Postby angelar » December 27th, 2011, 1:51 pm

I am a bit confused on this issue too. When I restrict a page from the dashboard on individual pages, and a user that doesnt have access to it clicks on it, they get an error page (see screenshot). How do I change this so it redirects them to the members option page? ( I am using Weaver theme). Am I suppose to use conditionals instead of the restriction option from the dashboard? In this one example I want only the level1 subscriber to see the page and sidebar. When I used conditional shortcodes on this page the user did see the message that they didnt have access but still could view the sidebar.

I would like every restricted page to redirect to the members options page.

In the S2member API/Scripting should I not use THE EASY WAY and other options below that? I am new to PHP but am willing and want to learn it. An example of redirect code would be great on how I can accomplish this. I see many examples in the s2member API/scripting but I dont see any URLS to actually force the user to the members page, and I dont see where the URLS for the membership page are suppose to go.

Any help greatly appreciated. I really want this to work for me.
Attachments
pagerestrictions.png
User avatar
angelar
Registered User
Registered User
 
Posts: 11
Joined: December 26, 2011

Re: Redirecting on Login and on Page restriction

Postby Cristián Lávaque » December 28th, 2011, 7:32 pm

Angela, what you're asking for is how it should be behaving: send to the Membership Options page everyone that tries to view a protected page/post.

Could you post the URL to your Membership Options Page? As well as a screenshot of the edit page for it.

And another of the Membership Options page panel, please. WP Admin -> s2Member -> General Options -> Membership Options Page
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Redirecting on Login and on Page restriction

Postby angelar » December 28th, 2011, 7:56 pm

OMG! I got it. I cant believe it, I just didnt set up the membership options page correctly! I didnt choose one!! Im not even blonde:>
User avatar
angelar
Registered User
Registered User
 
Posts: 11
Joined: December 26, 2011

Re: Redirecting on Login and on Page restriction

Postby Cristián Lávaque » December 28th, 2011, 8:38 pm

philipt18 wrote:Also, is there a way to do thing like recognize all pages that are children of a specific page (so I don't have to return to this code and keep adding page IDs)?


You may want to try working with these functions:
http://codex.wordpress.org/Function_Ref ... e_children
http://codex.wordpress.org/Function_Ref ... _ancestors

philipt18 wrote:So back to my question above, am I redirecting to multiple pages, or creating multiple sections on the Member Options page? An example or two would be greatly appreciated. Thanks.


You'd be adding alternative content to the same Membership Options page and show the right each based on the conditionals you create. For example:

Code: Select all
<?php
$restricted_pages 
= array(4, 5, 76, 89);
if (isset($_GET['_s2member_seeking']['page']) && in_array((int) stripslashes($_GET['_s2member_seeking']['page']), $restricted_pages)) { ?>
That page requires a paid membership. Get it now [button]
<?php } ?>


Other examples: WP Admin -> s2Member -> API / Scripting -> Membership Options Variables -> Code Samples
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Redirecting on Login and on Page restriction

Postby Cristián Lávaque » December 28th, 2011, 8:40 pm

angelar wrote:OMG! I got it. I cant believe it, I just didnt set up the membership options page correctly! I didnt choose one!! Im not even blonde:>


lol :)

I'm glad you figured out what the problem was.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010


Return to s2Member Plugin

Who is online

Users browsing this forum: Majestic-12 [Bot] and 2 guests

cron