• Skip to primary navigation
  • Skip to main content

RocketGeek

Home of WP-Members, The Original WordPress Membership Plugin

  • WordPress Plugins
    • WP-Members
      • FAQs
      • Quick Start
      • Documentation
      • Extensions
    • Advanced Options
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Download Protect
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Invite Codes
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • MailChimp Integration
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • PayPal Subscriptions
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Salesforce Web-to-Lead
    • Security
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Text Editor
      • Purchase the Plugin
      • Get the Pro Bundle
    • User List
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • User Tracking
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Memberships for WooCommerce
    • WordPass
  • Blog
    • Basics
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Store
    • Cart
    • Checkout
  • Contact
  • Log In
  • Show Search
Hide Search
Home » Filters » Adding user display name to the registration form

Adding user display name to the registration form

Chad Butler · Oct 8, 2012 ·

This article is provided free. Find out how you can get full access to premium content, including how-to articles and support forums, as well as priority email support and member exclusive plugin extensions..

 

WordPress does not allow for users to change their username, so neither does WP-Members.  However, it does allow for the use of “display name” which is the name that is displayed on the site when showing users’ names.   The default install of WP-Members does not make use of display name.  In fact, by default, it adds the user’s username to this field so that it is not empty in the database, just in case you are using that information somewhere else on the site (such as in a forum).

But what if you want to make use of the display name field?  How can you add that to the front-end user profile in WP-Members.  This post will show you how to add it to the registration form (which by default includes the user update form), and then how to show it only in the user update form.

Adding the display name field

The display name field as handled by WordPress is stored as an entry in the wp_usermeta table.  For those of you that may not be familiar with the WordPress default database structure and the WP-Members approach to user data, that is the same way all of the WP-Members extra fields are stored.  So adding this to the user profile and registration process is nothing more than adding it as a field in the WP-Members field manager.

The main item of importance when creating the display name field in the field manager is to know that WP stores this as “display_name” in the wp_usermeta table.  So when you create the field, to tie it into the WP native field, you need to give it the Option Name of “display_name” when you create the field.

Restricting the display name field to user update only

So adding the display name field is as simple as adding a new field in the field manager.  What if you want this to be limited to the user profile update and not part of the initial registration?

That is where the wpmem_fields filter hook comes in. This filter allows you to easily change what fields are displayed in the form.  The documentation for wpmem_fields displays how to use the filter to remove a field based on some criteria, which is what we will be doing in this example.  In this case, we will remove the “display_name” field if the form being displayed is the registration form.  That way the field is only included for user update.

So here’s the filter function to add to your functions.php file:

add_filter( 'wpmem_fields', 'my_remove_display_name_filter', 10, 2 );
function my_remove_display_name_filter( $fields, $tag ) {
 
    if ( 'register' == $tag ) {
        unset( $fields['display_name'] );
    }
     
    return $fields;
}

There is an extension of this tutorial that describes how to add the display name field to just the user profile update and use a dropdown selector similar to how the WP user profile screen is handled.

Filters filters, forms, registration, str_replace, tips, wpmem_register_form

Ready to get started?

Join Today!

© 2025 · butlerblog.com · RocketGeek is built using WordPress, WP-Members, and the Genesis Framework

  • butlerblog.com
  • WP-Members Support Subscription
  • Terms of Service
  • Privacy Policy
  • Refund Policy