I'm trying to make a form redirect to the current page, but it's currently redirecting itself to the homepage every time the form submits? I can't see anything wrong with the code itself?

<form method="post" accept-charset="UTF-8" enctype="multipart/form-data">
  {{ csrfInput() }}
  <input type="hidden" name="action" value="users/save-user">
  <input type="hidden" name="redirect" value="{{ craft.request.url }}">
  <input type="hidden" name="userId" value="{{ currentUser.id }}">
  <textarea id="summernote" name="fields[userAbout]">{{ currentUser.userAbout }}</textarea>
  <button class="btn btn-primary btn-md semi-bold mt-4" type="submit">Save Profile</button>
  • Little hint: if you remove the redirect at all it should always remain on the same page and doesn't redirect to another one unless you have certain events – Robin Schambach Apr 9 '19 at 12:57

I believe its because you are not "hashing" the URL. Either use this https://docs.craftcms.com/v3/dev/functions.html#redirectinput-url or as that the link also mentions:

<input type="hidden" name="redirect" value="{{ craft.app.request.absoluteUrl|hash }}">
| improve this answer | |

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.