<p>1) You can set the default user group through your admin:</p>

<p><img src="https://i.sstatic.net/D2p2Y.png" alt="enter image description here"></p>

<p>2) Also I'm pretty sure <code>&lt;input type="hidden" name="userGroups" = "1"&gt;</code> needs to be set to <code>&lt;input type="hidden" name="userGroups" value="1"&gt;</code> for it to work but I'd need to test to be sure.</p>

CC BY-SA 3.0
2014-09-12T11:45:50.030Z
Thx, I did point 1 and it worked. Point 2 didn't worked after I corrected my attributes... maybe it should be another name.
Lisa Van Daele
CC BY-SA 3.0
2014-08-29T15:27:10.980Z
2014-08-29T15:27:10.980Z
Adam McCombs
<p>I just started using Craft and I'm a little stuck with a public registration form.
I made a user group and wanted to add these to the saveUser form.</p>

<p>I found  <a href="https://craftcms.stackexchange.com/questions/1774/how-do-you-set-a-users-group-on-a-registration-form">this answer</a></p>

<p>but don't know where to find this code.</p>

<p>I'm working in a twig file. Do i have to make my own plugin for that? Or do I have to overwrite something?</p>

<pre><code>&lt;form method="post" action="" accept-charset="UTF-8"&gt;
    &lt;input type="hidden" name="action" value="users/saveUser"&gt;
    &lt;input type="hidden" name="redirect" value="/"&gt;
    &lt;input type="hidden" name="userGroups" = "1"&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;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="email"&gt;Email&lt;/label&gt;&lt;/h3&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;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;input type="submit" value="Register"&gt;
&lt;/form&gt;
</code></pre>

<p>I tried adding a userGroups hidden input but that didn't work. </p>

<form><registration>
Registration Form twig add to an usergroup
# Registration Form twig add to an usergroup

(Asked by: username_0 on 2014-08-29)

I just started using Craft and I'm a little stuck with a public registration form.
I made a user group and wanted to add these to the saveUser form.
I found  this answer
but don't know where to find this code.
I'm working in a twig file. Do i have to make my own plugin for that? Or do I have to overwrite something?

    
    
    

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

    {% from _self import errorList %}

    Username
    

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

    Email
    

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

    Password
    

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

    


I tried adding a userGroups hidden input but that didn't work.

**Tags:** form, registration


---

## 1 answers

### Answer by username_1 on 2014-08-29. Score: 3 | Accepted answer

1) You can set the default user group through your admin:

![enter image description here](https://i.sstatic.net/D2p2Y.png)

2) Also I'm pretty sure  needs to be set to  for it to work but I'd need to test to be sure.

> **Comments:**
> **username_0**: Thx, I did point 1 and it worked. Point 2 didn't worked after I corrected my attributes... maybe it should be another name.  

---

