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 user to the login page

Home Forums Community Forum Redirect user to the login page

This topic contains 2 replies, has 2 voices. Last updated by  adam chen 4 years, 10 months ago.

Topic Author Topic
Posted: Wednesday Feb 15th, 2012 at 1:31 pm #5231
adam chen
Username: adam1987

hi guys, with the help from david, I did achieve the method to redirect user to login page, but now the problem is I want to after login it will NOT redirect back to log in, seem it become a loop. Also, I choose to redirect logged in user to the profile page, maybe thats also the reason its loop came up, but I have to redirect user to profile page I think (the page has your user name, address, change password and etc), so that they can view what they did.

Here is the code, if anyone could help perfect it to achieve that. I will be really really appreciated. I took out the php tag so the code appear correctly

function dw_custom_redirect($vars = array()){

	//This redirects to the registration url (assuming it's a standard install)
	wp_redirect(site_url('/wp-login.php'));
	exit();
	
}

//This adds to the hook when the system calls for the "membership-options" page.
add_action("ws_plugin__s2member_before_wp_redirect_w_mop_vars","dw_custom_redirect");
  • This topic was modified 4 years, 10 months ago by  adam chen.
  • This topic was modified 4 years, 10 months ago by  adam chen.

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Wednesday Feb 15th, 2012 at 1:39 pm #5234
David Welch
Username: dwbiz05

try adding this in your function…

function dw_custom_redirect($vars = array()){

	//This redirects to the registration url (assuming it's a standard install)
	if( !is_user_logged_in() ){
	wp_redirect(site_url('/wp-login.php'));
	}
	exit();
	
}

Dave

Posted: Wednesday Feb 15th, 2012 at 2:07 pm #5236
adam chen
Username: adam1987

hi david, thanks again for your help.
First, I think I am not going to use Membership Option Page at all for now.
But is one more issue emerged.
Because there is a need for private area for the page for each user, so I setup the Login welcome page as the abc.com/%%current_user_login%%
But since its manually crated each area, so it turn out to be blank, and another funny issue is that: if I had a user with custom capability of useradam, then if 2nd user named useradam2, the blank page’s address will apear like abc.com/useradam, instead of abc.com/useradam2. I wonder if there is way to walk around it so that if the user does not have a user private page crated yet, it went back to home page, or if you could kindly hint me way to get the s2member to create that private page with corresponding custom capability filled once the user is created?

Thank a lot, you are the most helpful person in s2member community I ever met!

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