How to prevent duplicate usernames in WooCommerce

Published on: Updated: March 26, 2018

One of our WooCommerce clients recently asked how to prevent duplicate usernames. She wanted to know what would happen if a new customer creates an account on her WordPress e-commerce online shop and tries to add a username that is already in use.

WooCommerce has features built in to prevent duplicate usernames. Since so many websites use WooCommerce, I will describe the options to help anyone else who is worried about this.

Create username based on the user’s email address

How to prevent duplicate usernames in WooCommerceIf you log into the WordPress admin and go to WooCommerce > Settings > Account, you can scroll down to a section called Registration Options. This allows you to tick a box called ‘Automatically generate username from customer email’.

If you tick this box then when a customer creates an account during checkout, they will automatically be given a username based on the first part of their email address. Their username is not their actual email address, as most people assume. Instead, their username is the part of their email address which appears before the @. For example if my email is info@barn2.co.uk then my username will be ‘info’.

As you can see from this example, a lot of automatically generated usernames won’t be very unique – how many people have info@ email addresses?! WooCommerce detects duplicate usernames and avoids the problem by adding a number after any duplicates. For example if I create an account when there is already a user called ‘info’ then my username will be ‘info1’.

Many WooCommerce website owners aren’t keen on this option because a lot of people like to choose their username to make it easy to remember. Fortunately there is another option.

Allow WooCommerce customers to choose a username

You can untick the ‘Automatically generate username from customer email’ box in WooCommerce > Settings > Account Registration Options. This adds a field to your checkout page prompting customers to choose their own email address.

If a customer enters an email address that has already been chosen, WooCommerce will prevent any duplicate usernames. Instead of adding a number after the username, an error message will appear after you click the ‘Submit’ button. This prompts the customer to choose a different email address.

Which option is best?

As always, there are pros and cons of each option.

Some WordPress website owners like the convenience of automatically generating usernames. This is attractive because it’s one less field for the customer to fill in. Research into what makes an effective online form has reliably shown that the more information the customer is asked to enter, the less likely they are to complete the process. This is a big deal on a WooCommerce website as store owners need to prevent abandoned carts and checkouts.

But for overall user-friendliness, it’s nice for customers to be able to choose a username that will be easy for them to remember in future.

The decision largely depends on the purpose of your customer accounts. If customers will have little reason to log into their account in future then it’s best to automatically generate their username as this speeds up the checkout process. If you want to encourage repeat business, or if customers will be logging in for many different purposes (e.g. if you offer online courses or a membership area) then they’re more likely to want an easy-to-remember username. Think about your customers and choose the best option for them.

Filed under: WordPress Plugins ,