Craft 2.6.2963

I've got a password reset form on the front end which works correctly sending the email. However it doesn't redirect on submit, unless you are loggedin.

redirect works if logged in, but if I'm logged in I wouldn't be resetting my password. How to get the redirect working correctly?

This is my entire form:

<form method="post" accept-charset="UTF-8">
    {{ getCsrfInput() }}
    <input type="hidden" name="action" value="users/sendPasswordResetEmail">
    <input type="hidden" name="redirect" value="/password-reset-notice">

    <h3><label for="loginName">Username or email</label></h3>

    <li class="form__form-group form-group">
        <label class="form__label" for="email">Email Address</label>
        <input class="form__field form-control" type="text" name="loginName" id="loginName" placeholder="Email Address" value="{% if loginName is defined %}{{ loginName }}{% else %}{{ craft.session.rememberedUsername }}{% endif %}"/>

    {% if errors is defined %}
        <ul class="errors">
            {% for error in errors %}
                <li>{{ error }}</li>
            {% endfor %}
    {% endif %}

    <li class="form__form-group form-group">
        <input type="text" name="comment" tabindex="-1" class="form__field form__field--comment" />
        <button class="form__submit button button--lg" type="submit">Submit ›</button>
  • 2
    Is there a {% requireLogin %} somewhere? Such as in password-reset-notice? Apr 26 '17 at 20:14
  • Yes and if you put that as an answer I'll mark it correct
    – CreateSean
    Apr 27 '17 at 21:38

This issue is caused by the presence of the {% requireLogin %} tag in one of your Craft templates. Remove the tag from the template in question, and the redirect should work as expected.

Craft Docs: https://craftcms.com/docs/templating/requirelogin

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.