3

So I'm trying to setup public registration for the first time. I'm running into two problems:

  1. The users are not getting assigned to the default user group
  2. The password is not required but fails validation when there is 1-6 characters (as it should).

    <form method="post" accept-charset="UTF-8">
    {{ getCsrfInput() }}
    <input type="hidden" name="action" value="users/saveUser">
    <input type="hidden" name="redirect" value="">
    
    {% macro errorList(errors) %}
        {% if errors %}
            <ul class="errors">
                {% for error in errors %}
                    <li>{{ error }}</li>
                {% endfor %}
            </ul>
        {% 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">
    </form>
    

Must I enforce the password required client side?

EDIT: LOGOUT of the admin pages when testing registration (or just go into an icognito window). This fixed the password being blank passing validation issue AND the user group not getting assigned.

6

The users are not getting assigned to the default user group.

You're probably testing front-end user registration with an already logged in user account.

Make sure you log out of your current one first before you start testing creating new users.

The password is not required but fails validation when there is 1-6 characters (as it should).

Must I enforce the password required client side?

Yeah... currently you'll need to enforce it client-side for front-end registration. I'll see what we can do to improve that.

  • Cheers on logging out. For the password thing, I'd assume Craft should fail a registration if the password field is blank. At least that's what I want. – veritascs Nov 24 '14 at 0:12
  • Got it... updated the answer. – Brad Bell Nov 24 '14 at 0:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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