2

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 %}"/>
    </li>

    {% if errors is defined %}
        <ul class="errors">
            {% for error in errors %}
                <li>{{ error }}</li>
            {% endfor %}
        </ul>
    {% 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>
    </li>
</form>
2
  • 2
    Is there a {% requireLogin %} somewhere? Such as in password-reset-notice? Commented Apr 26, 2017 at 20:14
  • Yes and if you put that as an answer I'll mark it correct
    – CreateSean
    Commented Apr 27, 2017 at 21:38

1 Answer 1

1

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 and acknowledge you have read our privacy policy.

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