| Drupal

usersOne of our members came to us with a question about usernames.

After installing the Advanced Forum module, they noticed that Drupal was posting usernames. The same thing was happening for comments and elsewhere on the site.

Our member wondered if it was possible to replace these plain usernames with people's real names. Yes it is, if you use the Real name module.

media_1371653975043.png

Installing Real Name

We're going to need two modules:

Install and enable both of those modules.

Setting up the First Name and Last Name

  • Go to Configuration > Account settings > Manage fields
media_1371653247097.png

On this screen we're able to add fields to our user accounts. If that's surprising and you thought fields only applied to content, read our introduction to Drupal entities.

  • Add a field for First Name using Text as the type of data to store.
  • Add a field for Last Name using Text as the type of data to store.
media_1371653344427.png

Here's how the fields for your user accounts might look:

media_1371653669757.png
  • Go to Configuration > Real name

By default only the raw username is being shown, as you can see at the top of the page.

media_1371653832539.png

You can use Tokens to change what is displayed. Further down the page, you'll be able to see the tokens for First Name and Last Name.

  • Enter those tokens into the Realname pattern box:
media_1371653904535.png

Now if you visit the front of your site, you'll see that the First Name and Last Name have replaced the username:

media_1371653927442.png

About the author

Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.