Change Drupal Usernames with the Real Name Module
One 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.
One 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.
Installing Real Name
We’re going to need two modules:
- Real Name: https://drupal.org/project/realname
- Token: https://drupal.org/project/token
Install and enable both of those modules.
Setting up the First Name and Last Name
- Go to Configuration > Account settings > Manage fields
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.
Here’s how the fields for your user accounts might look:
- Go to Configuration > Real name
By default only the raw username is being shown, as you can see at the top of the page.
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:
Now if you visit the front of your site, you’ll see that the First Name and Last Name have replaced the username:
Nice!
Just FYI, there is also a handy hook you can use to alter the display of usernames: hook_username_alter() – [url=https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_username_alter/7]https://api.drupal.org/api/…[/url]
Danny
Thanks Danny. This member had actually been poking in the code trying to make this work. I’m sure that link will be useful.
I am using Realname which is great on a Drupal 7 commons site. However on the Edit account profile page it doesn’t display the realname id which I have set to firstname.lastname it displays the firstname underscore xxx (number) how do I update that to reflect the true display name used by the Realname module?
Is this realname module working fine with hybridauth users, I found it does not works.
Not working for me on poll module comments 🙁
Perfectly and simply explained, many thanks!
It was useful for my forum section, when i needed to hide real username (to keep safe a login data)
Awesome!!