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.

Users being directed to wp-admin

Home Forums Community Forum Users being directed to wp-admin

This topic contains 7 replies, has 2 voices. Last updated by  Bruce 3 years, 9 months ago.

Topic Author Topic
Posted: Thursday Mar 14th, 2013 at 6:35 pm #44654
Asif
Username: asifmandozai

This issue seems to happen when I give the permission ‘edit_posts’ to my users.

After logging in they seem to be redirected to the wp-admin page. My intention is to direct them to the custom dashboard page as defined in the “Login Welcome Page”

By giving this particular permission (edit_posts) with plugin “User Role Editor” it seems s2member is not behaving as expected.

I have noted a very similar discussion here with a hack to correct:
http://www.s2member.com/forums/topic/subscribers-not-taken-to-welcome-page/page/2/#post-40429

I have also updated my version to the latest v130221 in order to include the short names fix just in case.

I have tried Jason’s hack but it seems to have no effect.

Here is the code I dropped into a file called s2-hacks.php in directory /wp-content/mu-plugins/

has_cap('edit_posts'))
			return FALSE;
			
		return $what_s2_says;
	}
	

Any help would be greatly appreciated.
Thanks

List Of Topic Replies

Viewing 7 replies - 1 through 7 (of 7 total)
Author Replies
Author Replies
Posted: Monday Mar 18th, 2013 at 4:53 am #45033
Bruce
Username: Bruce
Staff Member

Thank you for reporting this important issue. We are sorry for the delay in response.

As mentioned in Jason’s post:

If you have some Users/Members with the edit_posts Capability, this can happen. s2Member will redirect anyone who can edit_posts, to the WP Dashboard and not to the Login Welcome Page.

Just to clarify, this is for the purpose of keeping Administrators, and the like from being redirected to the Login Welcome Page when they login. This way Administrators will not have to navigate to the Dashboard after logging in (as this is where they are normally going to be headed).

The issue with Jason’s hack is a wrong return value, just a simple error that can be fixed by changing line 8 to return TRUE;:

<?php
add_filter('ws_plugin__s2member_login_redirect', 's2_login_redirect', 10, 2);
function s2_login_redirect($what_s2_says, $vars = array())
	{
		$user = $vars&#91;'user'&#93;;
		
		if($user->has_cap('edit_posts'))
			return TRUE;
			
		return $what_s2_says;
	}

That should fix your issue. :-)

Posted: Monday Mar 18th, 2013 at 8:20 pm #45090
Asif
Username: asifmandozai

Hello Bruce,

thanks for the updated code. Unfortunately it seems to have no effect on where my users are redirected to after sining in. When having the edit_posts role permission enabled for users with role “access_s2member_level0” they all seem to be redirected to http://www.website.com/blog/wp-admin/

Posted: Thursday Mar 21st, 2013 at 2:22 am #45292
Bruce
Username: Bruce
Staff Member

thanks for the updated code. Unfortunately it seems to have no effect on where my users are redirected to after sining in. When having the edit_posts role permission enabled for users with role “access_s2member_level0″ they all seem to be redirected to http://www.website.com/blog/wp-admin/

I can confirm that the code that I posted works on in a normal installation. However I can note that this will NOT force a redirect if the redirect_to variable in the URL is set.

Please check the URL that you are trying to log in with. Make sure that is like this:

http://yoursite.com/wp-login.php

and does not have a redirect_to variable like the below:

http://yoursite.com/wp-login.php/?redirect_to=/wp-admin/
Posted: Thursday Mar 21st, 2013 at 1:56 pm #45369
Asif
Username: asifmandozai

Interesting. It seems to be working if I directly goto wp-login.php

Since that page is not an amazing one and for convenience purposes I have copied out the login form from the wp-login.php page and placed it directly into my html homepage in order to fit in with the design without much code bloat.

So the following form present on the homepage is what users are using. It seems to be not working with this code which was from the wp-login.php page. Any suggestions would be greatly appreciated if I need to do something with the snippet below.

<form name="loginform" id="loginform" action="http://www.website.com/login/wp-login.php" method="post">
      
<label for="user_login">Username</label>
<input type="text" name="log" id="user_login" class="input" value="" size="20" />

<label for="user_pass">Password</label>
<input type="password" name="pwd" id="user_pass" class="input" value="" size="20" />

<label style="color:#fff;"><input name="rememberme" type="checkbox" id="rememberme" value="forever" /> 
Remember Me  <a href="http://www.website.com/login/wp-login.php?action=lostpassword">Forgot Password</a></label>

<input type="submit" name="wp-submit" id="wp-submit" class="btn bbtn2 btn-large btn-info pull-right" value="Log In" />

<input type="hidden" name="redirect_to" value="http://website.com/login/" />
</form>
Posted: Thursday Mar 21st, 2013 at 5:59 pm #45406
Asif
Username: asifmandozai

I was experimenting a bit & seem to have found a solution,
Thanks for pointing me in the right direction Bruce.

If there is anything else I should look into lease don’t hesitate to let me know.

I had removed the hidden field which seemed to have a redirect_to within it:

<form> ...
<input type="hidden" name="redirect_to" value="http://website.com/login/" />
... </form>
Posted: Thursday Mar 21st, 2013 at 6:01 pm #45407
Bruce
Username: Bruce
Staff Member

Thanks for the follow-up.

Yes that looks like the issue. That hidden input is setting the redirect_to variable to /login/ on your website. I’m unsure where that’s actually pointing (perhaps it has something to do with your theme?). But that’s definitely where s2Member is getting overridden.

Posted: Thursday Mar 21st, 2013 at 6:01 pm #45408
Bruce
Username: Bruce
Staff Member

Thanks for the follow-up.

Yes that looks like the issue. That hidden input is setting the redirect_to variable to /login/ on your website. I’m unsure where that’s actually pointing (perhaps it has something to do with your theme?). But that’s definitely where s2Member is getting overridden.

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