Auto Login during Registration with Redirection to Home Page

Hi there

I have been using this wonderful plugin for years, and in particular have been using the pro version.

I would like to implement Auto Login on registration via the pro form.

I have followed this article but it does not work. Can anyone help me out and suggest something hat could work?

Any help would be appreciated

regards
Stef

There are several threads about this issue on this forum. Please search before posting. This is the one you need: Sign in the new user after Checkout

1 Like

Hi Tim

Thank you for the reply. I did come across your thread and maybe should of continued the discussion there. Apologies.

I did try that snippet but it does not work, im really confused as to why not.

regards
Stef

Actually, opening your own thread is fine. Otherwise everyone on that thread would get all the new comments. But it would have been useful to link to the other thread, explain what you’d tried, and what happened.

So could you explain where you put that code, how your Login Welcome Page is set up, and what happens when someone attempts to register?

The Code:

  1. The code was added to a blank file called s2-auto-login.php
  2. This file was placed into the folder: /wp-content/mu-plugins/
  3. Not sure if this new plugin needs to be manually activated anywhere? But i assume not and should work automatically?

What Happens:
A user signups with no issue. We just want it to redirect to home page and autologin in completion.
S2Member is set to allow users to create their own passwords.

My Setup:
My register page is hard coded and uses this inserting the short code for the form (demo site is no the actual site):

	 <div id="Registration-s2Box">
<?php echo do_shortcode('[s2Member-Pro-PayPal-Form register="1" level="0" ccaps="" desc="" custom="www.demosite.com" tp="0" tt="D" captcha="clean" success="http://www.demosite.com/your-registration-is-complete" /]'); ?>

Why didn’t you mention it at the outset that you were using a custom method of inserting the s2Member shortcode?

I have no idea if my code will work with what you are doing.

We ended up testing this with the short code embedded on a page (not using the above method) and it still did not work.

This is the short code we used on a regular page within word press:

[s2Member-Pro-PayPal-Form register=“1” level=“0” ccaps="" desc=“Signup now, it’s Free!” custom=“www.demosite.com” tp=“0” tt=“D” captcha=“clean” /]

Looks like the shortcode is too short… Means, there is missing options, I think. Please re-create it and try again.

Thank you Krumch,

I double checked an that is the code to be found under PayPal Pro Forms, under the Free Registration Forms.

Not sure what you are referring to or i may be mssing?

We have found a solution to this:

  1. We found a conflict with WP All In One Security- there is a setting that forces a user to be logged off after a certain amount of time. We needed to turn this off.

  2. We used this to allow the auto login after registration:

function auto_login_new_user( $user_id ) {
wp_set_current_user($user_id, $user_login);
wp_set_auth_cookie($user_id);
do_action( ‘wp_login’, $user_id );
wp_redirect( home_url() );
exit;
} add_action( ‘user_register’, ‘auto_login_new_user’ , 100 );

Hope this helps people.

Thanks for posting the solution, @stek :slight_smile: