1

How do I change the link that's sent in a forgot password email that's sent to front end users in Craft 3? The setPasswordPath config isn't working for me.

The users don't have access to the CP. In my global config settings I have 'setPasswordPath' => '/account/set-password' I have a template based on the doc's Set Password Form example that loads at mysite.test/account/set-password.

The email is sent via a template that is based on the doc's Forgot Password Form example.

The links in the emails look like this: mysite.test/actions/users/set-password?code=r8tyzUikpXko0b2o5A785TC73geK0jvh&id=a91a64a3-8869-4f0d-a11b-2ad54d69303c

I want them to link to my template like this: mysite.test/account/set-password?code=r8tyzUikpXko0b2o5A785TC73geK0jvh&id=a91a64a3-8869-4f0d-a11b-2ad54d69303c

What am I doing wrong?

1 Answer 1

2

If you really want to change the password action url (not the password path) you can only do that in your Twig template and use the |replace('actions/users/set-password', 'account/set-password') filter.

The action url is hard coded in PHP and I would suggest you not to change it unless you know what you are doing. It would by default route to an action that does several important things and then redirects to the passwordPath.

So when you replace the route you should include the logic into your custom controller or create a site url rule to the default action

7
  • I’m not sure I understand. I want to be able to control the styling/templating of the set password page and hopefully load it at a URL I pick. I want it to work just like the docs I linked to suggest, I just can’t get the links in the reset password emails to link to my custom template. What could be wrong with my setup? Commented Oct 30, 2018 at 6:33
  • So it's about changing the route as you described in your question but about changing the template path? Because these are two different topics. Setting another template path will only work if the user has no cp access and the setPasswordPath should work. Where does the link redirect you? Commented Oct 30, 2018 at 6:38
  • I solved it. Thanks for pointing me in the right direction and clarifying that the URL is card coded. Commented Oct 30, 2018 at 18:15
  • could you please explain how you solved it? I am in the same situation.
    – outline4
    Commented Oct 22, 2019 at 12:22
  • 1
    If the users have cp access they'll always see the craft style password form. Only site users will be redirected to the password path Commented Nov 28, 2019 at 18:13

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.