By default, WordPress sets a new member’s display name to their first and last name, or falls back to their username if no name is given. Depending on your membership site, you may want to display usernames for your members instead of their real names. This is common on community sites that use online personas.
If your site depends on usernames or you want to give your members a display name that keeps their identity private, you can use this code recipe to set each new member’s display name to match their username automatically at checkout.
Do You Need This Recipe?
This recipe is worth adding if:
- Your community is built around usernames or handles instead of real names, such as gaming, hobby, or persona-driven memberships.
- Members need privacy, and you do not want a real name showing up as their display name.
- You want a consistent, predictable display name for every member without relying on what they type into the name fields at checkout.
Best Practices and Considerations
This recipe only affects new members created after you add it. It does not change the display name for members who already have an account. If you need to update existing members too, you will need to update display names manually or have a developer run a one-time script.
About the Code Recipe
The pmpro_checkout_new_user_array filter runs during checkout, right before PMPro creates a new WordPress user account for a member. It passes the $new_user_array array of user data that will be used to create that account.
The array includes standard WordPress user fields such as user_login (the username), user_email, user_pass, and display_name.
This code recipe hooks into that filter to overwrite display_name with the value of user_login, so the account is created with the display name already set to match the username.
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.
How to Customize This Code Recipe
Combine first and last name instead: If you collect a first and last name at checkout as required fields, and want to combine those fields to use as a display name, replace line 17 with $new_user_array['display_name'] = $new_user_array['first_name'] . ' ' . $new_user_array['last_name'];.
Get Support From Our Team of Experts
Have a question about how to use this feature? Our Support Page outlines three ways to get support.
Our Max plans include hands-on help customizing your membership site and implementing new features. Upgrade to PMPro Max now »


