<p>You don't mention what errors you're getting, but if you leave username blank, it will be set to whatever the email address is by default.</p>

<p>Password for new user registration is a required field by default, though.</p>

<p>If you wanted to alter this behavior, you'd have to write your own custom <a href="https://pluginfactory.io" rel="nofollow noreferrer">plugin</a> and have your form post to your plugin's controller action that enforced whatever custom user registration business logic your needs require.</p>

CC BY-SA 3.0
2017-01-26T19:20:56.700Z
2017-01-26T19:20:56.700Z
Brad Bell
<p>I have a registration form that looks like this:</p>

<pre><code>&lt;form method="post" accept-charset="UTF-8"&gt;
      {{ getCsrfInput() }}
      &lt;input type="hidden" name="action" value="users/saveUser"&gt;
      &lt;input type="hidden" name="redirect" value=""&gt;

      {% macro errorList(errors) %}
        {% if errors %}
          &lt;ul class="errors"&gt;
            {% for error in errors %}
              &lt;li&gt;{{ error }}&lt;/li&gt;
            {% endfor %}
          &lt;/ul&gt;
        {% endif %}
      {% endmacro %}

      {% from _self import errorList %}

      &lt;div class="top-row"&gt;
        &lt;div class="field-wrap"&gt;
          &lt;label for="firstName"&gt;First Name&lt;span class="req"&gt;*&lt;/span&gt;&lt;/label&gt;
          &lt;input type="text" id="firstName" name="fields[firstName]" required {%- if account is defined %} value="{{ account.firstName }}"{% endif %}"&gt;
          {{ account is defined and account ? errorList(account.getErrors('firstName')) }}
        &lt;/div&gt;
        &lt;div class="field-wrap"&gt;
          &lt;label for="lastName"&gt;Last Name&lt;span class="req"&gt;*&lt;/span&gt;&lt;/label&gt;
          &lt;input type="text" id="lastName" name="fields[lastName]" required {%- if account is defined %} value="{{ account.lastName }}"{% endif %}"&gt;
          {{ account is defined and account ? errorList(account.getErrors('lastName')) }}
        &lt;/div&gt;
      &lt;/div&gt;

      &lt;div class="top-row"&gt;
        &lt;div class="field-wrap"&gt;
          &lt;label for="email"&gt;Email&lt;span class="req"&gt;*&lt;/span&gt;&lt;/label&gt;
          &lt;input id="email" type="text" name="email" {%- if account is defined %} value="{{ account.email }}"{% endif %}&gt;
          {% if account is defined %} {{ errorList(account.getErrors('email')) }}{% endif %}
        &lt;/div&gt;
        &lt;div class="field-wrap"&gt;
          &lt;label for="company"&gt;Company&lt;span class="req"&gt;*&lt;/span&gt;&lt;/label&gt;
          &lt;input type="text" id="company" name="fields[company]" required {%- if account is defined %} value="{{ account.company }}"{% endif %}"&gt;
          {{ account is defined and account ? errorList(account.getErrors('company')) }}
        &lt;/div&gt;
      &lt;/div&gt;



      &lt;div class="top-row"&gt;
        &lt;div class="field-wrap"&gt;
          &lt;label for="country"&gt;Country&lt;span class="req"&gt;*&lt;/span&gt;&lt;/label&gt;
          &lt;input type="text" id="country" name="fields[country]" required {%- if account is defined %} value="{{ account.country }}"{% endif %}"&gt;
          {{ account is defined and account ? errorList(account.getErrors('country')) }}
        &lt;/div&gt;
        &lt;div class="field-wrap"&gt;
          &lt;label for="applicationArea"&gt;Application area&lt;/label&gt;
          &lt;input type="text" id="applicationArea" name="fields[applicationArea]" {%- if account is defined %} value="{{ account.applicationArea }}"{% endif %}"&gt;
          {{ account is defined and account ? errorList(account.getErrors('applicationArea')) }}
        &lt;/div&gt;
      &lt;/div&gt;

      &lt;h3&gt;&lt;label for="username"&gt;Username&lt;/label&gt;&lt;/h3&gt;
      &lt;input id="username" type="text" name="username"
              {%- if account is defined %} value="{{ account.username }}"{% endif -%}&gt;

      {% if account is defined %}
        {{ errorList(account.getErrors('username')) }}
      {% endif %}

      &lt;h3&gt;&lt;label for="password"&gt;Password&lt;/label&gt;&lt;/h3&gt;
      &lt;input id="password" type="password" name="password"&gt;

      {% if account is defined %} 
        {{ errorList(account.getErrors('password')) }}
      {% endif %}

      &lt;div class="form-footer"&gt;
        &lt;input class="button button-block" type="submit" value="Send request"&gt;
        &lt;p class="back-to-login"&gt;&lt;a href="#login" class="switcher"&gt;&lt;svg width="10" height="10" role="img"&gt;&lt;use class="closebtn__use" xlink:href="/assets/img/svg_sprite/svg_sprite.svg#arrow-pointer-right"&gt;&lt;/use&gt;&lt;/svg&gt;Go back to login&lt;/a&gt;&lt;/p&gt;
      &lt;/div&gt;
    &lt;/form&gt;
</code></pre>

<p>I made the custom fields firstName, lastName, company, applicationArea and assigned them as user profile fields. </p>

<p>Problem is that I don't want the user to enter a password and username on registration but send them an activation mail later. If I register a user in the form above it is added to the user list and everything works fine.</p>

<p>If i however remove to following part (since I don't want the username and password to the registration form):</p>

<pre><code>&lt;h3&gt;&lt;label for="username"&gt;Username&lt;/label&gt;&lt;/h3&gt;
      &lt;input id="username" type="text" name="username"
              {%- if account is defined %} value="{{ account.username }}"{% endif -%}&gt;

      {% if account is defined %}
        {{ errorList(account.getErrors('username')) }}
      {% endif %}

      &lt;h3&gt;&lt;label for="password"&gt;Password&lt;/label&gt;&lt;/h3&gt;
      &lt;input id="password" type="password" name="password"&gt;

      {% if account is defined %}
        {{ errorList(account.getErrors('password')) }}
      {% endif %}
</code></pre>

<p>This last snippet comes from the standard Craft demo registration form.</p>

<p>Any suggestions how to make te registration form work without the username and password?</p>

<p>Thans in advance!</p>

<p>Ps: I use Craft CMS 2.6.2958</p>

<form><registration>
Registration form issue
# Registration form issue

(Asked by: username_0 on 2017-01-26)

I have a registration form that looks like this:

      {{ getCsrfInput() }}
      
      

      {% macro errorList(errors) %}
        {% if errors %}
          
            {% for error in errors %}
              {{ error }}
            {% endfor %}
          
        {% endif %}
      {% endmacro %}

      {% from _self import errorList %}

      
        
          First Name*
          
          {{ account is defined and account ? errorList(account.getErrors('firstName')) }}
        
        
          Last Name*
          
          {{ account is defined and account ? errorList(account.getErrors('lastName')) }}
        
      

      
        
          Email*
          
          {% if account is defined %} {{ errorList(account.getErrors('email')) }}{% endif %}
        
        
          Company*
          
          {{ account is defined and account ? errorList(account.getErrors('company')) }}
        
      



      
        
          Country*
          
          {{ account is defined and account ? errorList(account.getErrors('country')) }}
        
        
          Application area
          
          {{ account is defined and account ? errorList(account.getErrors('applicationArea')) }}
        
      

      Username
      

      {% if account is defined %}
        {{ errorList(account.getErrors('username')) }}
      {% endif %}

      Password
      

      {% if account is defined %} 
        {{ errorList(account.getErrors('password')) }}
      {% endif %}

      
        
        Go back to login
      
    

I made the custom fields firstName, lastName, company, applicationArea and assigned them as user profile fields. 
Problem is that I don't want the user to enter a password and username on registration but send them an activation mail later. If I register a user in the form above it is added to the user list and everything works fine.
If i however remove to following part (since I don't want the username and password to the registration form):
Username
      

      {% if account is defined %}
        {{ errorList(account.getErrors('username')) }}
      {% endif %}

      Password
      

      {% if account is defined %}
        {{ errorList(account.getErrors('password')) }}
      {% endif %}

This last snippet comes from the standard Craft demo registration form.
Any suggestions how to make te registration form work without the username and password?
Thans in advance!
Ps: I use Craft CMS 2.6.2958

**Tags:** form, registration

---

## 1 answers

### Answer by username_1 on 2017-01-26. Score: 1

You don't mention what errors you're getting, but if you leave username blank, it will be set to whatever the email address is by default.

Password for new user registration is a required field by default, though.

If you wanted to alter this behavior, you'd have to write your own custom [plugin](https://pluginfactory.io) and have your form post to your plugin's controller action that enforced whatever custom user registration business logic your needs require.


---

