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?

<form method="post" action="" accept-charset="UTF-8">
    <input type="hidden" name="action" value="users/saveUser">
    <input type="hidden" name="redirect" value="/">
    <input type="hidden" name="userGroups" = "1">

    {% macro errorList(errors) %}
        {% if errors %}
            <ul class="errors">
                {% for error in errors %}
                    <li>{{ error }}</li>
                {% endfor %}
        {% endif %}
    {% endmacro %}

    {% from _self import errorList %}

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

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

    <h3><label for="email">Email</label></h3>
    <input id="email" type="text" name="email"
        {%- if account is defined %} value="{{ account.email }}"{% endif %}>

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

    <h3><label for="password">Password</label></h3>
    <input id="password" type="password" name="password">

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

    <input type="submit" value="Register">

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

1 Answer 1


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

enter image description here

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

  • Thx, I did point 1 and it worked. Point 2 didn't worked after I corrected my attributes... maybe it should be another name. Sep 12, 2014 at 11:45

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.