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.

role based Welcome page redirect

Home Forums Community Forum role based Welcome page redirect

Tagged: 

This topic contains 12 replies, has 4 voices. Last updated by  Cristián Lávaque 4 years ago.

Topic Author Topic
Posted: Thursday Dec 6th, 2012 at 3:41 pm #33752

I like the fact that there’s a redirect to the welcome page for users that signed up via s2m, but I have another class of members that are just woocommerce shop customers, that I don’t want to have their logins redirected to the welcome page. Is there a way I can disable this redirect if the user logging in has a different role – “customer” for example?

I tried this, but it was ineffective:

add_action('init', 'normal_redirect_for_customers');
        function normal_redirect_for_customers(){
            if(!current_user_can('s2member_level1')){
                if (class_exists ("c_ws_plugin__s2member_login_redirects_r")){
										c_ws_plugin__s2member_login_redirects_r::remove_login_redirect_filters();
				}
				

            }
        }

Also, if a non-s2 user stumbles across the member page, I want them to be redirected as though they’re not a member at all.

If I could just disable the welcome page redirection alltogether, I could just create my own role-based redirects, but simply failing to select a welcome page does not disable redirection, it just redirects to page_id=0

List Of Topic Replies

Viewing 12 replies - 1 through 12 (of 12 total)
Author Replies
Author Replies
Posted: Thursday Dec 6th, 2012 at 4:32 pm #33771
Bruce
Username: Bruce
Staff Member

Hi Bryan,

You might want to check out the info at the bottom of Dashboard -› s2Member® -› General Options -› Login Welcome Page. You should be able to send users to a different URL when they are a different role, and then redirect them via PHP or JavaScript to the correct page.

Posted: Thursday Dec 6th, 2012 at 4:49 pm #33784

Bruce,

That helps to some degree if I wanted to redirect specific roles to specific pages, but in some cases, I don’t want to redirect the user at all, for example, there’s a login form on the woocommerce checkout page, but a customer logging in might not always be logging in from the checkout page, so I want to not redirect at all for non s2 users.

Posted: Thursday Dec 6th, 2012 at 5:09 pm #33787
Bruce
Username: Bruce
Staff Member

Hi Bryan,

You can stop login redirects by putting this into a Must Use plugin, by putting the following code into a .php file within your /wp-content/mu-plugins/ directory (create it if you don’t have it)

<?php
add_filter('ws_plugin__s2member_login_redirect', '__return_false', 10, 2);
&#91;/hilite&#93;

s2Member gives you data to get user data on this filter. You can do something like this:

&#91;hilite pre_code&#93;
<?php
add_filter('ws_plugin__s2member_login_redirect', 's2hack_s2member_redirect_stop', 10, 2);

function s2hack_s2member_redirect_stop ($bool, $vars) {
	extract($vars);
	
	if ($user->has_cap('capability_for_woothemes'))
		return false;
		
	else
		return $bool; 
}
  • This reply was modified 4 years, 1 month ago by  Bruce.
Posted: Thursday Dec 6th, 2012 at 5:30 pm #33796

Ah! that’s perfect!
Thanks.

Posted: Thursday Dec 6th, 2012 at 5:48 pm #33801
Bruce
Username: Bruce
Staff Member

No problem. Let us know if you have any issues with that.

Posted: Monday Dec 10th, 2012 at 11:59 am #34147

I think this should be considered a bug – The welcome page is protected against non-members only. The above redirect allows me to prevent non s2member users from being redirected to the welcome page, but I can’t use the restriction settings to restrict the page to s2member users.

Posted: Monday Dec 10th, 2012 at 12:23 pm #34151

Correction: when I set the welcome page using the select box, the welcome page doesn’t get protected at all – even from non-logged in users. I am able to set protection on the page if I enter the URL in the box below, however.

…. this appears to be an issue with caching. I needed to set the welcome page to never be cached (page caching is disabled for logged in users, though)

Posted: Monday Dec 10th, 2012 at 12:25 pm #34152

perhaps you could automatically add in nocache directives in members-only pages which are user-level protected to prevent caching plugins from caching them.

Posted: Tuesday Dec 11th, 2012 at 7:14 am #34224

s2Member does what it can to prevent caching of restricted pages. Object and database caching are known to cause trouble and you should disable those in your caching plugin to avoid trouble. Sometimes caching still happens despite the settings and s2Member’s efforts, but I’ve only seen that happen rarely and it’d be due to reasons specific to the installation.

Posted: Saturday Dec 15th, 2012 at 12:37 pm #34756
Robert Adams
Username: aqb

This is a big issue for me as well. I’ve tried everything mentioned in this post but my woocommerce users with the role “customer” are still being redirected to the membership options page. Help!

Posted: Saturday Dec 15th, 2012 at 1:25 pm #34757
Robert Adams
Username: aqb

Update. I installed the User Role Editor plugin. For the role “Customer” I checked the box “access_s2member_level0” under custom capabilities. That stopped users with the role of “customer” from being redirected to the membership options page. Not sure if this is a good long term solution, but it works for now.

It would be nice to have some sort of built-in feature within the s2member pro console that would address this issue more easily. I think this situation will start to present itself more often as there are alot of people using ecommerce plugins like woocommerce in conjunction with s2member.

Posted: Monday Dec 17th, 2012 at 1:26 am #34808

Thanks Robert, we’ll keep this in mind.

s2Member restrictions work with s2Member access capabilities only, so the “customer” role, not being one that has the s2Member access capabilities, didn’t have access to the restricted content until you edited it.

I’m glad you figured it out and thanks for the update. :)

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