Business Bloomer
  • About
  • WooCommerce Blog
  • Online Courses
  • Login
  • 0
  • About
  • WooCommerce Blog
  • Online Courses
  • Login
  • 0

WooCommerce: Deny Automatic Login Upon Registration @ My Account

> Published: Aug 2019
> Blog Category: WooCommerce Tips
> Blog Tags: Customer Registration, My Account
> Blog Comments: 16 Comments
Tweet

Join 17,000+ WooWeekly subscribers

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.

Right after registration, user is not logged in and a success notification is displayed instead.

PHP Snippet: Deny Auto Login After Registration @ WooCommerce My Account

/**
 * @snippet       Deny Login Upon Registration @ WooCommerce My Account
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.7
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_filter( 'woocommerce_registration_auth_new_customer', '__return_false' );

Related posts:

  1. WooCommerce: Change User Role for New Customers
  2. WooCommerce: Separate Login, Registration, My Account Pages
  3. WooCommerce: File Upload @ My Account Registration Form
  4. WooCommerce: Add New Tab @ My Account Page
  5. WooCommerce: Add First & Last Name to My Account Register Form
  6. WooCommerce: Hide or Rename a My Account Tab
  7. WooCommerce: How to Merge My Account Tabs
  8. WooCommerce: Allow Users to Edit Processing Orders
  9. WooCommerce: Rename “My Account” If Logged Out @ Nav Menu
  10. WooCommerce: Add a Custom Download File @ My Account

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

Follow @rmelogli
Category: WooCommerce Tips
Tags: Customer Registration, My Account

Post navigation

Previous post: WooCommerce: WooCart Managed Hosting
Next post: WooCommerce: File Upload @ My Account Registration Form

16 thoughts on “WooCommerce: Deny Automatic Login Upon Registration @ My Account”

  1. Boutique PcLanD
    July 14, 2022

    Hello,

    Unfortunately the code does not work permanently, I have customers who are not disconnected!

    Weird

    Reply
    1. Rodolfo Melogli
      July 18, 2022

      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?

      Reply
      1. Boutique PcLanD
        August 17, 2022

        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?

        Reply
        1. Rodolfo Melogli
          August 22, 2022

          Could be. Disable all plugins but Woo and switch theme, and test the snippet again

          Reply
  2. sg sg
    April 16, 2021

    How can we do the reverse, login the customers when they checkout in Woocommerce?

    Reply
    1. Rodolfo Melogli
      April 20, 2021

      Wait, doesn’t that work like that already?

      Reply
  3. Mark
    November 5, 2020

    Hi

    Do you perhaps have advice for auto log in for an elementor widget?

    Mark

    Reply
    1. Rodolfo Melogli
      November 25, 2020

      No idea sorry

      Reply
  4. sagarweb
    June 20, 2020

    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

    Reply
    1. Rodolfo Melogli
      June 28, 2020

      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!

      Reply
  5. Jordan
    February 24, 2020

    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)?

    Reply
    1. Rodolfo Melogli
      February 27, 2020

      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!

      Reply
  6. Stef
    August 26, 2019

    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.

    Reply
    1. Rodolfo Melogli
      August 29, 2019

      Great!

      Reply
      1. Serge
        April 10, 2020

        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

        Reply
        1. Rodolfo Melogli
          April 14, 2020

          Try disabling all plugins and theme and use this snippet with latest WooCommerce only. LMK

          Reply
Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts
  • WooCommerce: Related Products Custom Heading & Subheading
  • WooCommerce: Display Stock Status For External Products
  • WooCommerce: Display Product Grid @ Order Emails e.g. Related Products
  • WooCommerce: Capitalize All Product Names
  • WooCommerce: Add a Third Description @ Single Product Page
About Business Bloomer

With 100,000 (and growing) monthly organic sessions, Business Bloomer is the most consistent, most active and most complete WooCommerce development/customization blog.

Of course this website itself uses the WooCommerce plugin, the Storefront theme and runs on a WooCommerce-friendly hosting.

Join 75,000+ Monthly Readers & 16,500+ Subscribers.

Become a Business Bloomer Supporter.

Join BloomerArmada and become an Official Business Bloomer Supporter:
easy-peasy, and lots of perks for you.
See your Benefits →
Popular Searches: Visual Hook Guides - Checkout Page - Cart Page - Single Product Page - Add to Cart - Emails - Shipping - Prices - Hosting
Latest Articles
  • WooCommerce: Related Products Custom Heading & Subheading
  • WooCommerce: Display Stock Status For External Products
  • WooCommerce: Display Product Grid @ Order Emails e.g. Related Products
  • WooCommerce: Capitalize All Product Names
  • WooCommerce: Add a Third Description @ Single Product Page
Latest Comments
  • Rodolfo Melogli on WooCommerce: Separate Login, Registration, My Account Pages
  • Rodolfo Melogli on WooCommerce: Separate Login, Registration, My Account Pages
  • Rodolfo Melogli on WooCommerce: Related Products Custom Heading & Subheading
  • Rodolfo Melogli on WooCommerce: Switch Shop Columns Responsively
Find Out More
  • Become a WooCommerce Expert
  • WooCommerce Blog
  • WooCommerce Online Courses
  • WooCommerce Weekly
  • Bloomer Armada
  • Affiliate Program
  • Contact
Contact Info

Ciao! I’m Rodolfo Melogli, an Italian Civil Engineer who has turned into an international WooCommerce expert. You can contact me here:

Email: [email protected]

Twitter: @rmelogli

Hire me by the hour: Get Quote ยป

VisaMastercardAmexPayPal Acceptance Mark
Business Bloomer © 2011-2023 - Terms of Use - Privacy Policy