User Documentation

Using Email Addresses for Login instead of Username

User allows you to enable a feature that lets you have your members login to your site with their email address instead of their username. This can be done by selecting Yes for the Email as Username option in the User control panel area. This setting applies to new members only and is NOT retroactive. As in, all existing site members will not be able to login with their email address (unless they update their profiles one by one, or you run a query. The reason for this is that this setting just allows the users email address to override and become the username as well. Of course, there's a few other things you'll need to get in order to complete your setup:

You'll need to update your Register form to handle this new change. Basically, you need to REMOVE the email field completely from your form, and then re-label your username field to be referred to as Email Address. Your register form might look something like this now:

{exp:user:register
    return="user/registered"
}
    <p>
        <label for="screen_name">Screen Name</label>
        <input name="screen_name" id="screen_name" />
    </p>
    <p>
        <label for="email">Email</label>
        <input name="username" id="email" /> {!-- Notice the field name is 'username' --}
    </p>
    <p>
        <label for="password">Password</label>
        <input type="password" name="password" id="password" />
    </p>
    <p>
        <label for="password_confirm">Confirm Password</label>
        <input type="password" name="password_confirm" id="password_confirm" />
    </p>
{if captcha}
    <p>
        <label for="captcha">Please enter in the word you see:</label>
        {captcha}
        <input type="text" name="captcha" id="captcha" />
    </p>
{/if}
    <p>
        <label>
            <input type="checkbox" name="accept_terms" value="y" />
            Accept Terms?
        </label>
    </p>
    <p>
        <button type="submit">Register</button>
    </p>
{if no_results}
    <p>
        You're currently logged in, and must be logged out to view this form.
    </p>
{/if}
{/exp:user:register}

Your Edit Profile template will need to be modified as well, following the same steps as above:

{exp:user:edit
    return="user/edit/success"
}
    <p>
        <label for="screen_name">Screen Name</label>
        <input name="screen_name" id="screen_name" value="{screen_name}" />
    </p>
    <p>
        <label for="email">Email</label>
        <input name="username" id="email" value="{username}" /> {!-- Notice the field name is 'username' --}
    </p>
    <p>
        <label for="password">Password</label>
        <input type="password" name="current_password" id="password" />
    </p>
    <p>
        <button type="submit">Update</button>
    </p>
{/exp:user:edit}

And lastly your Login form will have to be modified as well, following same principle as above:

{exp:member:login_form
    return="user/profile"
}
    <p>
        <label for="email">Email</label>
        <input name="username" id="email" />
    </p>
    <p>
        <label for="password">Password</label>
        <input type="password" name="password" id="password" />
    </p>
    <p>
        <button type="submit">Log In</button>
    </p>
{/exp:member:login_form}

In the event you're making this change to a site with existing members, you'll want to consider this:

  • Because the {username} variable will now output a users email address ({email} will still continue to display the email address as well), be sure that any publicly visible reference to the {username} variable on your site is replaced with {screen_name} or an equivalent variable.
  • New users can login to your site with the regular Login form. Existing members with username style logins can still login to your site with the same regular Login form. If you plan to let both types fly for a while, you might want to consider labeling the login form with Email or Username: as both will be applicable.
  • When members with username style logins try to edit their profile, it will throw them an error saying they have not submitted a valid email address (for their username). All they need to do is enter their email address for their username (which would be labeled as Email Address now anyway) and it will submit successfully. Just remember that they might need to know that their login information has changed at this point.
  • You can run a query to update all existing username style members to become email addresses instead. Just go to the SQL Query Form (EE CP > Utilities › SQL Manager › Query Form) and enter this query:

UPDATE exp_members SET username = email

Support

Having problems setting up and/or using User? Support is offered from 10am to 4pm EST weekdays. Send us an email at help@eeharbor.com and we will respond as quickly as we can.