Is there a specific or preferred way to set the username for new user registrations to be their email address?

At the moment my user signup form contains both fields:

<!-- Username -->
  <label for="username">Username</label>
    <input type="text" id="username" name="username" placeholder="joesmith" {%- if account is defined %} value="{{ account.username }}"{% endif -%}/>
    {% if account is defined %}
        {{ _self.errorList(account.getErrors('username')) }}
    {% endif %}

<!-- Email -->
  <label for="email" >Email</label>
    <input type="text" id="email" name="email" {%- if account is defined %} value="{{ account.email }}"{% endif -%}/ autocapitalize=off autocorrect=off>
    {% if account is defined %}
        {{ _self.errorList(account.getErrors('email')) }}
    {% endif %}

1 Answer 1


I believe you're looking for the conveniently named useEmailAsUsername config setting.

When that is set to true, any new user that is saved with a valid email address will have that copied over to the username field as well.

  • 1
    Now all you need to do is mark it as the answer. :P
    – Brad Bell
    Commented Jul 23, 2014 at 18:45
  • 2
    This made me weep with joy. So convenient and smoothly implemented.
    – Ray
    Commented Oct 7, 2014 at 16:48
  • This is just what I needed. It would be nice if it was documented on the User registration form page in the docs. docs.craftcms.com/v3/dev/examples/user-registration-form.html
    – Tim Print
    Commented Jul 11, 2019 at 10:41
  • Added a note to that page @TimPrint.
    – Matt Stein
    Commented Oct 10, 2020 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.