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.

About: Erik Lopes de Oliveira

Sorry, I've not written a description yet. I'll get to it soon!


Topics I'm Subscribed To

Viewing topic 1 (of 1 total)
Topic Count Last Reply
Not redirecting after register new member

By:  Erik Lopes de Oliveira in: Community Forum

voices: 2
replies: 3

3 years, 9 months ago  Eduan

Viewing topic 1 (of 1 total)

Topics I've Started

Viewing topic 1 (of 1 total)
Topic Count Last Reply
Not redirecting after register new member

By:  Erik Lopes de Oliveira in: Community Forum

voices: 2
replies: 3

3 years, 9 months ago  Eduan

Viewing topic 1 (of 1 total)

My Latest Replies (From Various Topics)

Viewing 1 replies (of 1 total)
Author Replies
Author Replies
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.

Viewing 1 replies (of 1 total)

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.