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.

Problem with your Client Portal System

Home Forums Community Forum Problem with your Client Portal System

This topic contains 5 replies, has 3 voices. Last updated by  David Welch 4 years, 9 months ago.

Topic Author Topic
Posted: Friday Mar 16th, 2012 at 11:53 am #8362
adam chen
Username: adam1987

Hi, Dear Rep:

I been searching for an answer for a while now regarding the client portal setup for S2member.
Seem after a recent update, every new registered user that login from default login page (http://mysite.com/wp-login.php)will be loading into that ‘private page’ for the user straight, but I dont want that happen since the page is not really created at that moment. I rather want to log the user into his or her profile page for the first login after registration.
In other word, I want to redirect user to a specific page if the person try to login through default login page since whoever login through my login sidebar work just fine that logged into the profile page.

I really like s2member, and this issue is freaking me out for a long time now.

Please help me on this thank you!

  • This topic was modified 4 years, 9 months ago by  Raam Dev. Reason: Technical Support question, not Pre-Sales Question; moved thread to Community Forum

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Friday Mar 16th, 2012 at 12:51 pm #8375
Raam Dev
Username: Raam
Staff Member
Technical support question, not Pre-Sale (wrong forum).

Moving this thread into Community Forum so you have a chance to receive assistance from other site owners. If you’d like priority support from s2Member®, please re-post this topic in our Customer Support Forum and we’ll take a closer look for you.

For further details, please read our Support Policy.

Posted: Friday Mar 16th, 2012 at 1:06 pm #8376
adam chen
Username: adam1987

Ok, Ram….so what now? lol

Posted: Friday Mar 16th, 2012 at 1:27 pm #8378
David Welch
Username: dwbiz05

You may be able to circumvent the login redirect with a hook. Maybe something like this:

<?php
add_action('find the right hook','my_login_function');

function my_login_function($user_id){
	//put a function here to get whatever name or username or id or whatever you are using as the page title.
	$sql = "";
	$un = mysql_fetch_array(mysql_query($sql));
	$username = $un[''];
	
	//Check to see if there is a page with that title in the system.
	$sql = "SELECT ID FROM wp_posts WHERE post_title = '".$username."' AND post_status = 'publish' AND post_type = 'page' LIMIT 1";
	$count = mysql_num_rows(mysql_query($sql));
	
	if($count == 1){
		//Change the username to a slug like the page
		$page_slug = strtolower($username);	
		$page_slug = str_replace(' ','-',$page_slug);
		wp_redirect(site_url($page_slug));
	}
	else {
		wp_redirect(site_url('profile')); //replace profile with your profile page slug
	}
}

?>

I haven’t taken the time to find all the right hooks and everything, but that might help do what you want with a little updating.

Dave

Posted: Friday Mar 16th, 2012 at 5:35 pm #8426
adam chen
Username: adam1987

Hi, David:

Thanks for the reply, I made up one according to your template:
*But I am kinda lost on what to put on the first part?which is the code below
“//put a function here to get whatever name…”

However, what I did is here, is that correct?
What I intent to do:
1. The user will has a single client specific page LINK created (the link will be able to access through a specific short code) once the user name is registered. However the PAGE itself is NOT exist yet, so that why there is 404 page after login, because login-welcome-page is setup as “http://mysite.com/%%current_user_login%%/&#8221;.
I need to maintain this address inside the login-welcome-page to let the client portal runs.

2.The code you gave me seem will achieve the purpose but I don’t really get the meaning of the first part. please help thanks again!

Btw the page slug means I need to use page id? or simply the page’s link? my profile page link is simply http://www.abc.com/trial/profile, so I replace all the slug with profile, is that accurate? or should I replace it with page id?

Below is modification:

<?php
add_action('find the right hook','my_login_function');

function my_login_function($user_id){
	//put a function here to get whatever name or username or id or whatever you are using as the page title.
	$sql = "";
	$un = mysql_fetch_array(mysql_query($sql));
	$username = $un[''];
	
	//Check to see if there is a page with that title in the system.
	$sql = "SELECT ID FROM wp_posts WHERE post_title = '".$username."' AND post_status = 'publish' AND post_type = 'page' LIMIT 1";
	$count = mysql_num_rows(mysql_query($sql));
	
	if($count == 1){
		//Change the username to a slug like the page
		$page_slug = strtolower($profile);	
		$page_slug = str_replace(' ','-',$profile);
		wp_redirect(site_url($profile));
	}
	else {
		wp_redirect(site_url('id="http://mysite.com/trail1/profile/"')); //replace profile with your profile page slug
	}
}

?>
Posted: Saturday Mar 17th, 2012 at 4:37 pm #8469
David Welch
Username: dwbiz05

LOL, I was trying to not do everything for you… lol!

Ok,

1. ‘find the right hook’ means we have to find the right hook… I don’t know off the top of my head but I’ll see if I can find it and update this post.

2. I don’t know if this will work but try this:

<?php
add_action('ws_plugin__s2member_during_login_redirect','my_login_function');

function my_login_function(){
	//Check to see if there is a page with that title in the system.
	$sql = "SELECT ID FROM wp_posts WHERE post_title = '".S2MEMBER_CURRENT_USER_LOGIN."' AND post_status = 'publish' AND post_type = 'page' LIMIT 1";
	$count = mysql_num_rows(mysql_query($sql));
	
	if($count == 1){
		wp_redirect(site_url(S2MEMBER_CURRENT_USER_LOGIN));
	}
	else {
		wp_redirect(site_url('trial/profile'));
	}
}

?>

Let me know if that works,

Dave

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