If you’ve enabled customer registration on the My Account page, you will know that a new user is automatically logged in as soon as they successfully register.
This is great – however in certain cases it could be “dangerous” (for example, if you need to manually approve each user).
As I was searching through the WooCommerce plugin code, I found a great action filter that can immediately stop this from happening – I love one-liners! So, here’s the quick fix.

PHP Snippet: Deny Auto Login After Registration @ WooCommerce My Account
/**
* @snippet Deny Login Upon Registration @ WooCommerce My Account
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 3.7
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_registration_auth_new_customer', '__return_false' );
Hello,
Unfortunately the code does not work permanently, I have customers who are not disconnected!
Weird
Yep, that’s weird, I don’t see why it shouldn’t work all the times. Do you have some sort of server-side cache?
Yes it’s a dedicated server, with php 7.4.30 then apache and ngnix proxy!
I also have a module that allows the activation of customer accounts, this sends an email to the customer to confirm his mailbox! Maybe it’s a conflict?
Could be. Disable all plugins but Woo and switch theme, and test the snippet again
How can we do the reverse, login the customers when they checkout in Woocommerce?
Wait, doesn’t that work like that already?
Hi
Do you perhaps have advice for auto log in for an elementor widget?
Mark
No idea sorry
hi, this works but is there a way to change the message?
i used a customer registration redirect after registration to redirect to another page but it only worked in php 5 but it doesnt seem to work on php 7
Hi there, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
This is a great little snippet. Is it possible to use this filter to deny auto login after customer checkout completion (and when a new account is automatically created for the customer)?
Hey Jordan, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
This is great Rodolpho! It’s nice to have them confirm in their email in case bots are creating accounts with other people’s emails. I see it often.
Great!
Hi,
Its a great website and good source of usefull tips and recomendations. However this snippet does not work for me. User still auto login during checkout in Woocommerce.
I have tried other snippets but none of them work.
I just don’t understand if I need to enable or disable Woccomerce default function in order to make it work?
Thanks
Try disabling all plugins and theme and use this snippet with latest WooCommerce only. LMK