Register Form

Generate necessary markup to create a User register form.


By default, username, email, password, and password_confirmation fields are all required. However, if login_type is set to email in site/settings/users.yaml, the username field can be omitted.

Example

A basic registration form, with validation errors.

{{ user:register_form }}

    {{ if errors }}
        <div class="alert alert-danger">
            {{ errors }}
                {{ value }}<br>
            {{ /errors }}
        </div>
    {{ /if }}

    <label>Username</label>
    <input type="text" name="username" value="{{ old:username }}" />

    <label>Email</label>
    <input type="email" name="email" value="{{ old:email }}" />

    <label>Password</label>
    <input type="password" name="password" />

    <label>Password Confirmation</label>
    <input type="password" name="password_confirmation" />

    <button>Register</button>

{{ /user:register_form }}

Additional Fields

You are allowed to add any additional fields to your registration form, and they will be added to the user’s account provided that they exist in the user.yaml fieldset.

Any submitted data that does not exist in the fieldset will be completely ignored.

Additional fields will be validated as per your fieldset validate rules.

New user roles

Most of the time, new members will need some roles assigned to them so that they can do different things on your site. You get to choose these roles by adding the ids of the roles, in an array called new_user_roles in your site/settings/users.yaml file. When a user successfully registers as a member, their account will automatically be assigned the roles in this list.

It’s best to remember that these are starting roles for the user. You can later either manually add roles to users in their files, update their account through the Control Panel, or have add-ons automatically add or remove roles as needed when users perform certain tasks.


Parameters

redirect

string

Where the user should be taken after successfully registering.

allow_request_redirect

boolean

When set to true, the redirect parameter will get overridden by a redirect query parameter in the URL.


Variables

errors

array

An array of validation errors.

Last modified on July 31, 2018