<p>I believe you're looking for the conveniently named <a href="https://docs.craftcms.com/v3/config/config-settings.html#useemailasusername" rel="nofollow noreferrer"><code>useEmailAsUsername</code></a> config setting.</p>

<p>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.</p>

CC BY-SA 3.0
2014-07-23T18:45:03.887Z
Now all you need to do is mark it as the answer. :P
Brad Bell
CC BY-SA 3.0
2014-10-07T16:48:14.187Z
This made me weep with joy. So convenient and smoothly implemented.
Ray
CC BY-SA 4.0
2019-07-11T10:41:02.723Z
This is just what I needed. It would be nice if it was documented on the User registration form page in the docs. https://docs.craftcms.com/v3/dev/examples/user-registration-form.html
Tim Print
CC BY-SA 4.0
2020-10-10T20:38:20.867Z
Added a note to that page @TimPrint.
Matt Stein
CC BY-SA 4.0
2014-07-23T18:36:51.053Z
2019-06-20T20:59:34.640Z
2019-06-20T20:59:34.640Z
Brad Bell
<p>Is there a specific or preferred way to set the username for new user registrations to be their email address?</p>

<p>At the moment my user signup form contains both fields:</p>

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

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

<users>
Use email address as username
# Use email address as username

(Asked by: username_0 on 2014-07-23)

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
    
    {% if account is defined %}
        {{ _self.errorList(account.getErrors('username')) }}
    {% endif %}


  Email
    
    {% if account is defined %}
        {{ _self.errorList(account.getErrors('email')) }}
    {% endif %}

**Tags:** users


---

## 1 answers

### Answer by username_1 on 2014-07-23. Score: 18 | Accepted answer

I believe you're looking for the conveniently named [`useEmailAsUsername`](https://docs.craftcms.com/v3/config/config-settings.html#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.

> **Comments:**
> **username_1**: Now all you need to do is mark it as the answer. :P  
> **username_2**: This made me weep with joy. So convenient and smoothly implemented.  
> **username_3**: This is just what I needed. It would be nice if it was documented on the User registration form page in the docs. https://docs.craftcms.com/v3/dev/examples/user-registration-form.html  
> **username_4**: Added a note to that page @TimPrint.  

---

