No more usernames! Setting up Drupal 7 for Email Login

Sorry, the user name 'Super Incredibly Good Looking Jim' is already taken...

I don't need another username. I really don't need another username on a site that I am not going to have a public profile. There are sites where having a username makes perfect sense, and then there are those that don't.

Reasons you may need to have a Username:

If the site offers a public profile

For use in internal commenting

For use in internal forum

For use in internal messaging

Even in some of these cases, we could get away with using a display name. We will explore how to set up a Display Name that is separate from core's login funtionality below.

I am not building Twitter. Nor am I building Ello, Reddit, Pinterest, or Periscope. In most cases, I only have administrators and content creators accessing the site. Trying to keep the login process as painless as I can for my users, I will use an email address field as the unique identifier. I would venture to guess that everyone online has at least one of those.

Replacing Usernames in Drupal 7

Thanks to the Drupal Email Registration Module, we can offer our users a simple way to register accounts and log in. While this creates the functionality we need, it is only the first step in our journey. This module does not remove the required username functionality from Drupal core, it meerly replaces it.

A username is still created in the system. By default, it is the name part of the email address, underscore, ID. (name_17 in [email protected] is the 17th account). While the Email Registration Module has solved our login problem, the username can still be used in a variety of places like site emails, core comments, some node displays, some view displays, etc...

To fix this, we will enlist the help of the Drupal Real Name Module. This module, along with help from the Drupal Token Module allows you to set a field, or fields that are on the User Profile as the default name for the users. You can also set if this is to be used in comment and node displays.

Step by Step

Download and Install the Email Registration, and Real Name modules. drush dl -y email_registration drush en -y email_registration drush dl -y realname drush en -y realname

Set permissions at: /admin/people/permissions

Add fields to your User Profile here: /admin/config/people/accounts/fields

Configure Real Name Pattern here: /admin/config/people/realname

Configure your site emails at: /admin/config/people/accounts You want to replace your salutations to use the Real Name field - [current-user:original:name], or one of the individual fields you added to the user, and you want to replace any instance of username, with the email token field - [current-user:mail]



Those are the basics. Depending on the build of your site, you may need to configure more, but these steps will get most of the heavy lifting done.

See Also:

The Drupal LoginToboggan Module offers users email OR username login, plus a lot more great features. It is worth exploring also, and can be used in combination with the modules mentioned above.