This post covers two ways to control the allowed format and structure of usernames for new members.

Banner Image for Customizing Username

Allow Members to Use an Email Address as Their Username

If your site doesn’t have a need for public or frontend-facing usernames, you may want to simplify checkout by setting a user’s email address as their username. With the vast number of sites we are all members of, it has become extremely difficult to remember what username I created where. It’s much easier to remember your login credentials when using an email address as your login name.

During a default membership checkout, users are prompted to create a “Username” and enter their “Email Address”. This code recipe will take the information inserted in the Email Address field of the Membership Checkout page and use it as the member’s username.

Use a members email address as a username paid memberships pro image

The Code Recipe

Note: You need to add Custom CSS to your site to hide the user field.

Reformat Usernames to Use Allowed Characters After Checkout

Reformat usernames to use allowed characters after checkout

This code recipe will convert a member’s username to match your specific rules. In this example, we convert all characters to lowercase and replace any spaces found in the username with underscores. If a member inputs a username like “John Doe”, then this will be changed to “john_doe”.

One of our members recently had a support request related to the format of usernames. Their request was for appearance reasons, but there are other cases where you would like usernames to follow stricter guidelines. For example, if you are using a single sign on bridge to integrate your members with a third-party application, you may need to match the requirements of usernames for that external site.

This code can also be useful in cases where the member’s username appears in other features of your site, such as on a BuddyPress profile.

The Code Recipe

Adding the Recipe to Your Website

You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.

Free Course: Membership Site Development—The Basics

Develop a deeper understanding of membership site development in this beginner-level course. Learn how to make your site work better, save yourself time and money, and improve your site's performance.

Featured Image for Membership Site Development Course: The Basics
Was this article helpful?