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.

Login Redirect Help

Home Forums Community Forum Login Redirect Help

This topic contains 6 replies, has 2 voices. Last updated by  Alex Robertson 4 years, 7 months ago.

Topic Author Topic
Posted: Thursday Apr 19th, 2012 at 4:42 pm #11287

List Of Topic Replies

Viewing 6 replies - 1 through 6 (of 6 total)
Author Replies
Author Replies
Posted: Thursday Apr 19th, 2012 at 10:36 pm #11305
David Welch
Username: dwbiz05

This might be a good place to start. I think it’s similar to what you described above.

http://www.s2member.com/forums/topic/problem-with-your-client-portal-system/#post-8469

Hope it helps,

Dave

Posted: Friday Apr 20th, 2012 at 3:56 am #11335

Thanks David,

I will try the below code later. Hopefully i should just be able to amend wp_redirect(site_url(‘trial/profile’)); to my home page link. :)

<?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'));
	}
}

?>

Would it be best to setup a child theme to insert this code? also where would i paste it? somewhere in the header file?

Many Thanks,

Posted: Friday Apr 20th, 2012 at 8:50 am #11371
David Welch
Username: dwbiz05

You would usually put it in functions.php (so a child theme may be good) or in a file located in a folder like this wp-content/mu-plugins/s2hacks.php. You may need to create this folder and file.

Yes, you should be able to ammend those redirects to whatever page you want. :)

Hope it works,

Dave

Posted: Friday Apr 20th, 2012 at 2:49 pm #11413

I pasted the following into functions.php just before the closing ?> tag but when i log in as a user that i have not created a page for its stil trying to take them to a page called the same as there username?

Any help would be great?

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('blog/home'));
	}
}
Posted: Thursday Apr 26th, 2012 at 12:17 am #11896
David Welch
Username: dwbiz05

UPDATE:

There were a couple errors in the code. The correct code should be something like 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_name = '".S2MEMBER_CURRENT_USER_LOGIN."' AND post_status = 'publish' AND post_type = 'page' LIMIT 1";
    $count = mysql_num_rows(mysql_query($sql));
    if($count == 0){
        wp_redirect(site_url('general-page-slug'));
	exit;
    }
}
?>

Sorry for the errors to anyone who was trying to use it.

Dave

Posted: Monday May 14th, 2012 at 4:42 am #13380

I have now solved this issue. – Please close.

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