Drupal User Registration and Login with Email instead of Username

Drupal’s default registration process is more complicated than it should be. To simplify the process I like my users to sign up and log in with only their email address and password.

There are various ways to deal with that issue, with Login Toboggan being one of the most popular ones. However, I rarely need all the other stuff that comes with this module and I prefer small modules that focus on a single task. Besides, Login Toboggan only allows to login with an email address as an alternative to the username, it doesn’t remove the need to create a username in the first place.

So what I found best for my needs is a combination of the Email Registration module and a tiny custom module.

E-Mail registration enables registration and login with email address only. It also auto-generates a username with the fist part of the user’s email address. Almost what I wanted, but I prefer to have username and email the exact same value. Luckily, Email Registration provides a hook called hook_email_registration_name(). So we can implement this hook in our own module to alter the username as we wish.

To exactly match the username with the user’s email address that is as easy as:

 * Implements hook_email_registration_name(). 
function MYMODULE_email_registration_name($edit,$account) {
  return $account->mail;

Leave a Reply