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.
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.
- Navigate to /admin/user/profile (Administer > User Management > Profiles).
- Add a new “single-line textfield”.
- 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)
- For Title, type something like “First name”.
- For Form Name, we think “profile_firstname” is a good choice.
- For Visibility, select the option “Public field, content shown on profile page but not used on member list pages”.
- Check the box “The user must enter a value”.
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.
- Navigate to /admin/user/realname (Administer > User Management > RealName).
- Make sure “Show realname in nodes”, “Overwrite user fields in view to show realnames”, and “Override username theme” are all checked.
- Select the Fields tab. You will be redirected to the Module tab automatically. Select the “Core Profile” radio button and click Use this Module.
- You will now be taken to the Fields tab. Check the box for the field(s) you created.
- 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”).
- Click the Save button.
- You will now be prompted to “Rebuild RealNames”. Proceed with this.
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).