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™

Redirect Profile page based on role

s2Member Plugin. A Membership plugin for WordPress®.

Redirect Profile page based on role

Postby guyu2 » December 29th, 2011, 3:58 pm

I have a setup where I want to redirect free subscribers away from the Wordpress Profile page, but not paid members. Can this be done with the short code something like this:

[s2Member-Profile role="subscriber"/]

If not is there another way?

Appreciate the help.

8-) Guy
User avatar
guyu2
Registered User
Registered User
 
Posts: 2
Joined: December 29, 2011

Re: Redirect Profile page based on role

Postby Eduan » December 29th, 2011, 4:27 pm

Check this video by the Lead Developer and please tell me if it helps:
http://www.s2member.com/paypal-modifica ... ons-video/

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: Redirect Profile page based on role

Postby Raam Dev » December 29th, 2011, 4:32 pm

Hi Guy,

So you want regular paying subscribers to see a profile page after logging in, but the free subscribers to go somewhere else?

To send all users to the Profile Page after logging in, you'll want to select the Profile Page as the Login Welcome Page in WP Admin -> s2Member -> General Options -> Login Welcome Page.

Then the most simple way to redirect free subscribers is to use Advanced/PHP Conditionals (WP Admin -> s2Member -> API/Scripting -> Advanced/PHP Conditionals) to check if the user viewing the Profile Page is a free subscriber (s2member_level0). If they are a free subscriber, then the HTML Meta Refresh redirects them to another page.

Code: Select all
<?php if (current_user_is("s2member_level0")) { ?>
<meta http-equiv="refresh" content="0; url=http://example.com/free-subscribers-area">
<?php } ?>


You'll need to install and activate the PHP Execution plugin before adding this code to the top of your Profile Page (i.e., wherever you're using the [s2Member-Profile /] shortcode.

The downside to this method is that the free subscriber will probably see the contents of the Profile Page for a brief moment before being redirected away.

If you want to get more advanced, you can use a Custom Page Template for your Profile Page and then add the PHP code directly to that page template, preventing the [s2Member-Profile /] shortcode from ever loading for free subscribers.
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011

Re: Redirect Profile page based on role

Postby guyu2 » December 29th, 2011, 8:45 pm

Hi,

Thanks to both Eduan and Raam Dev.

I tried both your suggestions and ran into several issues I could not resolve - with my very limited knowledge.

Did find a solution that works by adding a function to my functions.php file as follows:
Code: Select all
function subscriber_redirect(){
  if( is_admin() && !defined('DOING_AJAX') && ( current_user_can('subscriber') ) ){
    wp_redirect('http://mydomain.com/?page_id=xxxx');
    exit;
  }
}
add_action('init','subscriber_redirect');


Ps: Eduan, I think that the video you pointed me to is going to prove very useful in future. Appreciate it. :D
User avatar
guyu2
Registered User
Registered User
 
Posts: 2
Joined: December 29, 2011

Re: Redirect Profile page based on role

Postby Eduan » December 29th, 2011, 9:40 pm

OK, glad I could help in something. :)

Anything else you need just ask.
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: Redirect Profile page based on role

Postby Raam Dev » December 30th, 2011, 3:47 pm

Glad to help! Let us know if you have any other questions. :)
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 3 guests

cron