Auto-login issues

I have successfully implemented autologin (https://s2member.com/kb-article/auto-login-on-registration/) on my local version of my site but when using it on my live site, it is not working. I have copied all the same settings, use the exact same plugins, same theme, etc.

Any ideas where I can go to investigate the issue? I have looked in log files and console for errors and see nothing.

Thanks

I have tried this on my second site that uses s2member and I am having the same issue.

If you want help, you need to be much more specific. What steps are you or your users taking, and what exactly is happening?

Sorry, the lack of specifics is because there really isn’t much more to it and I am not getting an sort of error logged.

The auto login from the link I shared is supposed to automatically log in the user after they create an account. It’s not doing that. So when a user creates an account, they still have to log in.

How are they creating an account and what is happening when they do?

The account creation happens with the [s2Member-Pro-Stripe-Form] shortcode. This works exactly as it is supposed to. When a user signs up, their account is created and the “success” variable works like it’s supposed to, sending them to the correct URL after they sign up.

So everything works exactly as it’s supposed to except that they are not logged in.

Have you worked with Auto-login before and have it working? My understanding is that by placing the code in the mu-plugins folder, the user is just supposed to be logged in after they sign up. Is that correct?

So basically, if S2Member has been working on my site for over a year and now all I want to change is make it so new users are logged in automatically after signing up, I just need to follow the directions ((https://s2member.com/kb-article/auto-login-on-registration/) and that should be all I have to do, correct?

This is what I did and they are not being logged in automatically.

Yes, I have worked with that. The code you’re using hasn’t worked for a while. Well, actually, it does work to log someone in, but it lacks an explicit redirect to the Welcome page.

I have posted working code for this before on this forum. You can find it by searching, but here’s the URL for that thread: Sign in the new user after Checkout

If you don’t call your LWP “Welcome”, then you could change the penultimate line to this:
wp_safe_redirect( S2MEMBER_LOGIN_WELCOME_PAGE_URL );

I actually don’t even care if it redirects the person to a welcome page so if that part is not working, I am not that concerned right now. The issue is that the person is not logged in.

I tried your code as well and the same result.

Then you have something else on your site that’s causing the problem. You will need to disable everything else and test it with as clean an installation as you can.

I just tried that. I disabled all plugins except S2Member and the same thing is happening. I tried both your code and the official S2Member code.

It still works (with all my plugins) on my local version, which is an exact duplicate of the site.

I’m not sure what else to do.

That suggests some sort of caching issue, like using Cloudflare. If you can’t see anything like that, then I suggest that you talk to your host in case if they are running some caching that you’re not aware of.

I decided to just go code my own function using “do_action(‘wp_login’, …”. It’s working for me now.

Thanks for the replies.