Replacing Usernames with Real Names in Drupal

Chris Toler

Written by Chris Toler

Hello my name is badge for drupal real name connotation

Replacing usernames with real names sounds like it should be easy, and it is. It hasn’t always been this way, though. Once upon a time, you’d need to create a theme override in the theme’s template.php, which is understandably scary to non-developers. We’ve put together this quick tutorial to help guide you through the simple process of getting this working on your Drupal environment.

Dependencies

There are a few things you’ll need:

Creating your Name fields

This can be done in a few ways. You can define a single field called “Full name” (or similar), or a field for First Name, and another for Last Name. It’s completely up to you, but we prefer having two fields.

  1. Navigate to /admin/user/profile (Administer > User Management > Profiles).
  2. Add a new “single-line textfield”.Creating your Name fields in Drupal
  3. Define a category if you wish. This is optional. (If you do create a category, the fields associated with it will show up a tab with the Category’s name within the user profile edit section)
  4. For Title, type something like “First name”.
  5. For Form Name, we think “profile_firstname” is a good choice.
  6. For Visibility, select the option “Public field, content shown on profile page but not used on member list pages”.
  7. Check the box “The user must enter a value”.Creating your Name fields in Drupal - part 2
  8. Save.

Repeat this for the Last Name field, unless you decided to go with a single (Full Name) field.

Configuring the RealName module

Now we need to configure RealName to display the fields you’ve created instead of the actual username. A few other options should be tweaked, as well.

  1. Navigate to /admin/user/realname (Administer > User Management > RealName).
  2. Make sure “Show realname in nodes”, “Overwrite user fields in view to show realnames”, and “Override username theme” are all checked.Configuring the RealName module in Drupal
  3. Save.
  4. Select the Fields tab. You will be redirected to the Module tab automatically. Select the “Core Profile” radio button and click Use this Module.Configuring the RealName module in Drupal - Part 2
  5. You will now be taken to the Fields tab. Check the box for the field(s) you created.
  6. In the Name Pattern field, type %# for each field. (Example: If the first field is First name, and the second is Last Name, type “%1 %2” in the Name Pattern field. If you just used a single Full Name field and it’s first in the list, just type “%1”).Configuring the RealName module in Drupal - Part 3
  7. Click the Save button.
  8. You will now be prompted to “Rebuild RealNames”. Proceed with this.Configuring the RealName module in Drupal - Part 4

You’re all done!

Everything is done. Navigating to any page that would display a username (user profile, post information, comments) should now display the Real Name, if it exists.

Quick tip: If you enabled this AFTER a lot of user accounts already exist, you may want to inform your users to log in and add these values (since you set it as required).

Chris Toler

Written by Chris Toler

Need technology experts?

Contact Us