Radical Design Course by Jack McDade

From the creator of Statamic

Learn how to make your websites standout and be remembered.

Taking your approach on designing things actually makes it fun, more natural, and overall easier.

— Dominik, Developer

User:Forgot_Password_Form Tag

This tag is used to create a "forgot my password" form for your users.

Overview

Users will enter their email address in the form and, upon submitting, an email will be sent with a link to create a new password.

Unless you set a redirect parameter, the user will be redirected back to the same page after submitting, and the success variable will allow you to show a success message.

Example

{{ user:forgot_password_form reset_url="/reset-password" }}
 
{{ if errors }}
<div class="bg-red-300 text-white p-2">
{{ errors }}
{{ value }}<br>
{{ /errors }}
</div>
{{ /if }}
 
{{ if success }}
<div class="bg-green-300 text-white p-2">
{{ success }}<br>
</div>
{{ /if }}
 
<label>Email</label>
<input type="text" name="email" value="{{ old:email }}" />
 
<button type="submit">Send Reset Email</button>
 
{{ /user:forgot_password_form }}

The email will contain a link to the URL specified in the reset_url parameter, along with extra query parameters. On that URL you must have a user:reset_password_form tag to finish the task and let the user set their new password.

Hot Tip!

The user needs to be logged out for this tag to do anything. You may want to wrap the form in {{ if logged_out }}{{ /if }}.

The email

Once the form is submitted, an email will be sent containing the URL for resetting the password.

This email is bundled with Statamic and will work for most people out of the box. However, if you'd like to customize it, you can.

The template is named user-reset and should contain a {{ reset_url }} variable, which is the generated reset URL.

Parameters

redirect

string

Where the user should be taken after requesting a password reset.

error_redirect

string

The same as redirect, but for failed password reset requests.

allow_request_redirect

boolean

When set to true, the redirect and error_redirect parameters will get overridden by redirect and error_redirect query parameters in the URL.

reset_url

string

The URL containing your Reset Password Form. A link to this URL will be included in the email, along with the appropriate query parameters.

HTML Attributes

Set HTML attributes as if you were in an HTML element. For example, class="required" id="forgot-password-form".

Variables

Variable Type Description

errors

array

An array of validation errors.

old

array

An array of previously submitted values.

success

string

A success message.

email_sent

string

An alias of the success variable.

Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →