1

After a logged-in user updates their profile on the front end, I'd like to redirect them to the same page but show a success message. I believe I can do this with craft.request.getPost() but it's not working for me. Code below:

<input type="hidden" name="test" value="xyz">

and then

{% set success = craft.request.getPost('test') %}
{% if success %}
    Success message
{% endif %}

I can see "test" in my dev tools network tab but can't seem to access it.

4

Not possible – any input values added to your profile editing form (such as test in your case) will be included in the POST request to the users/saveUser controller action, but they won't actually be included in the redirect request back to the page (or to whatever URL is in your form's hidden redirect input).

As a workaround you can always check for the Flash notice that the UsersController sets after the user is successfully saved:

{% if craft.session.getFlash('notice') == 'User saved.'|t %}
    <p>Success message!</p>
{% endif %}
  • Wow, awesome! Thank you so much! That worked and was really helpful! – Ryan Jun 21 '16 at 23:53

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.