1

According to the Craft docs {% requireLogin %} on a page should return the user to the same page after login. This doesn't work for me - the returned page is always the one set in 'postLoginRedirect'.

In the config file, I've got this setup:

    'postLogoutRedirect' => 'members/logout',

    'postLoginRedirect' => 'members',

    'loginPath' => 'members/login'

What am I missing?

3

I may be missing something here, but you probably just want to remove the postLoginRedirect setting from the config?

You could also try adding {{ redirectInput(craft.app.user.returnUrl) }} to the form.

craft.app.user.returnUrl should return the URL that triggered the login.

| improve this answer | |
  • I tried that, but if it's removed the user is sent to the default post login URL. – Andrew Jun 18 at 13:08
  • Hi, have updated my answer with another option. craft.app.user.returnUrl should give you the url that you want to redirect to, so setting the {{ redirectInput() }} value to that should sent the user back to the page that triggered the login. – dmatthams Jun 18 at 13:38
  • Yes that's done it! – Andrew Jun 19 at 14:10

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.