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.

Not redirecting after register new member

Home Forums Community Forum Not redirecting after register new member

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

Topic Author Topic
Posted: Sunday Mar 31st, 2013 at 1:05 am #46187

Hi!! I’m testing my new site on WAMP server @ localhost and after a free costumer submit a register form the page is not redirecting to the welcome page. The form is properly being writen in my Database and the user / member is being created, if they refresh the browser (F5) and click in login link they will be abble to login and then the redirection is working fine. My issue is only redirecting after submit the register form.

My debbug log shows:

LOG ENTRY: Sun Mar 31st, 2013 @ precisely 3:41 am UTC
PHP v5.4.3 :: WordPress® v3.5.1 :: s2Member® v130221
Memory 19.50 MB :: Real Memory 20.50 MB :: Peak Memory 19.83 MB :: Real Peak Memory 20.50 MB
localhost/BLOG/wp-login.php?action=register
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31
array (
  'user_id' => 12,
  'password' => false,
  'pagenow' => 'wp-login.php',
  'email_config' => true,
  'processed' => 'yes',
  'user' => 
  WP_User::__set_state(array(
     'data' => 
    stdClass::__set_state(array(
       'ID' => '12',
       'user_login' => 'regularuser',
       'user_pass' => '$P$BJFgAz8zWgskGEMO3ZUopocEbEHA1I1',
       'user_nicename' => 'regularuser',
       'user_email' => 'regularuser@domain.com',
       'user_url' => '',
       'user_registered' => '2013-03-31 03:41:40',
       'user_activation_key' => '',
       'user_status' => '0',
       'display_name' => 'regularuser',
    )),
     'ID' => 12,
     'caps' => 
    array (
      'subscriber' => true,
    ),
     'cap_key' => 'wp1_capabilities',
     'roles' => 
    array (
      0 => 'subscriber',
    ),
     'allcaps' => 
    array (
      'read' => true,
      'level_0' => true,
      'access_s2member_level0' => true,
      'subscriber' => true,
    ),
     'filter' => NULL,
  )),
  '_pmr' => 
  array (
    'user_login' => 'regularuser',
    'user_email' => 'regularuser@domain.com',
    'ws_plugin__s2member_registration' => '0f958ca3c0',
    'ws_plugin__s2member_custom_reg_field_user_pass1' => 'password',
    'ws_plugin__s2member_custom_reg_field_user_pass2' => 'password',
    'ws_plugin__s2member_custom_reg_field_first_name' => 'regularuser',
    'ws_plugin__s2member_custom_reg_field_last_name' => 'level0',
    'redirect_to' => '',
    'wp-submit' => 'Registrar-se',
    0 => '',
  ),
  'custom_reg_display_name' => 'full',
  'reg_cookies' => false,
  'current_role' => 'subscriber',
  'role' => 'subscriber',
  'php_errormsg' => 'Undefined index: ws_plugin__s2member_registration_return_url',
  'level' => '0',
  'ccaps' => '',
  'email' => 'regularuser@domain.com',
  'login' => 'regularuser',
  'ip' => '::1',
  'custom' => '',
  'subscr_id' => '',
  'subscr_gateway' => '',
  'cv' => 
  array (
    0 => '',
  ),
  'eot' => '',
  'auto_eot_time' => '',
  'notes' => '',
  'opt_in' => false,
  'fname' => 'regularuser',
  'lname' => 'level0',
  'name' => 'regularuser level0',
  'pass' => 'password',
  'fields' => 
  array (
  ),
)

I tried to manualy force the redirection but I coldnt find where to. So I searched for

'ws_plugin__s2member_registration_return_url' 

in my files (I’m using notepad++) and it returned the registrations.inc.php at lines 971 and 992…unfortunetly I’m not a PHP harduser and I’m stucked.

Is there a way to manualy fix this and write a value for

'redirect_to' => ''

?? Where can I manualy write a value for this ??

Thank You!

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Tuesday Apr 2nd, 2013 at 10:04 pm #46426
Eduan
Username: Eduan
Moderator

Hello Erik,

There seems to be a misunderstanding here. This is to be expected.

When users register they’re asked to login, once they login they’re redirected to the login welcome page.

If the user is paying for the membership, he will pay, then register, and then login, then the login welcome page.

Hope this clears something up. :)

– Eduan

Posted: Wednesday Apr 3rd, 2013 at 12:27 pm #46476

SOLUTION FOUND!

Thanks for the help man!! But it seems to be a nonmissunderstood. It is not expected to a user log in after register, beacuse this is not the right UX and if we didnt get it, almost every web site or web app automaticaly log in users after register.

There is two ways to do it:

– The first is to add a funcion on the wordpress/wp-login.php file to fix the redirect issue (THIS WILL NOT LOG IN USERS ONLY FIX THE PHP ERROR FOR REDIRECTION:

THE ERROR MESSEGE SAYS:

'php_errormsg' => 'Undefined index: ws_plugin__s2member_registration_return_url',

So we simply add this funtion on the wordpress/wp-login.php file:

Search for the //Check the email adress (In my file is @ line 322) and it looks like this:

// Check the e-mail address
	if ( $user_email == '' ) {
		$errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please type your e-mail address.' ) );
	} elseif ( ! is_email( $user_email ) ) {
		$errors->add( 'invalid_email', __( '<strong>ERROR</strong>: The email address isn&#8217;t correct.' ) );
		$user_email = '';
	} elseif ( email_exists( $user_email ) ) {
		$errors->add( 'email_exists', __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' ) );
	}
	
	do_action( 'register_post', $sanitized_user_login, $user_email, $errors );
	
	$errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email );

	if ( $errors->get_error_code() )
		return $errors;

	$user_pass = wp_generate_password( 12, false);
	$user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email );
	if ( ! $user_id ) {
		$errors->add( 'registerfail', sprintf( __( '<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ) );
		return $errors;
	}

		update_user_option( $user_id, 'default_password_nag', true, true ); //Set up the Password change nag.

	c( $user_id, $user_pass );
	
	return $user_id;
}

Right before the update_user_option and the update_user_option is where you will put your new function:

// Check the e-mail address
	if ( $user_email == '' ) {
		$errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please type your e-mail address.' ) );
	} elseif ( ! is_email( $user_email ) ) {
		$errors->add( 'invalid_email', __( '<strong>ERROR</strong>: The email address isn&#8217;t correct.' ) );
		$user_email = '';
	} elseif ( email_exists( $user_email ) ) {
		$errors->add( 'email_exists', __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' ) );
	}
	
	do_action( 'register_post', $sanitized_user_login, $user_email, $errors );
	
	$errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email );

	if ( $errors->get_error_code() )
		return $errors;

	$user_pass = wp_generate_password( 12, false);
	$user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email );
	if ( ! $user_id ) {
		$errors->add( 'registerfail', sprintf( __( '<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ) );
		return $errors;
	}
	
	// HERE IS WHERE YOU PUT YOUR REDIRECT FUNC
	if (! $erros) {
		do_action(wp_redirect('../BLOG/?page_id=82'));
		}
		

		update_user_option( $user_id, 'default_password_nag', true, true ); //Set up the Password change nag.

	wp_new_user_notification( $user_id, $user_pass );
	
	return $user_id;
}

NOTES: YOU MUST SET THE “../” BEFORE THE URL BECAUSE IF YOU DONT WORDPRESS WILL TRY TO HIT THIS PAGE WITHIN THE ACTUAL URL. YOU WILL HAVE SOMETHING LIKE http://WWW.YOURSITE.COM/WP-LOGIN.PHP?THE-PAGE-YOU-PUT-IN-THE-FUNCION AND IT WONT WORK. SO YOU HAVE TO TELL THE SERVER TO BACK TO THE ROOT ARCHIVE AND THEN LOAD A NEW PAGE THIS IS WHAT ‘../’ IS FOR.

IF YOU WHANT USERS TO GET BACK TO YOUR INDEX YOU SIMPLY PUT ‘../YOURSITE-ARCIEVE-NAME’ (I.E. ‘../BLOG’)

IF YOU WHANT USERS TO GET REDIRECTED TO A THANK YOU PAGE JUST PUT THE ROUTE TO THAT PAGE (I.E. ‘../BLOG/?page_id=82’

REMEMBER: IF YOU USE ROLE BASED PAGES THE PAGE RULES MUST BE ABLE TO THE SUBSCRIBER LEVEL OTHERWISE THEY WONT BE ABLE TO LOAD THE PAGE.

– Second and simpler. IF YOU WANT USERS TO BE AUTOMATICALY LOGED IN JUST DOWNLOAD THE WP-AUTO-LOGIN PLUGIN. SIMPLE AS BREATHING.

DOWNLOAD LINK: http://blog.coderaustralia.com/wordpress-plugins/wordpress-auto-login

Thats all…

I hope this may help other people =)

Thanks.

Posted: Thursday Apr 4th, 2013 at 11:17 pm #46661
Eduan
Username: Eduan
Moderator

Thanks for the solution. :)

With s2Member I’m pretty sure this flow is on purpose. But if it isn’t I’m glad you found the solution. :)

– Eduan

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