Trigger {% if form.posted_successfully? %} with URL

Via StackOverflow, I saw that {% if form.posted_successfully? %} can be triggered by adding a GET attribute to the URL. For example, ?contact_posted=true will trigger the contact form, and ?customer_posted=true will trigger the newsletter subscription form. Is it possible to do the same for the password recovery form? I’ve tried using **?**recover_customer_password=true, but no luck. Is there any official documentation in regards to this?

1 Like

Hi @BigSkillet ,

You can use this condition for all forms:

{% if form.posted_successfully? %}
Comment posted successfully!
{% endif %}

So instead of each form being different like the code you mentioned you would use this condition for all.

Refer https://shopify.dev/api/liquid/objects/form#form-posted_successfully

Hope it helps!

Yes, I understand the conditional can be used for all forms. The question is – how to manually trigger the success message for development purposes, specifically {% form ‘recover_customer_password’ %}.

Hi @BigSkillet ,

‘development purposes’: What does it mean?

You can still use it for {% form ‘recover_customer_password’ %}. Refer https://github.com/Shopify/dawn/blob/main/templates/customers/login.liquid

Hope it helps!

When I said “development purposes,” I meant that I’m developing a custom theme and would like to test the success message without running into a “too many attempts” issue. This can be done with a contact form by adding a ?contact_posted=true attribute to the browser URL. I’d like to know if there’s a similar attribute that can be added to test a recover password message.

Hi @BigSkillet ,

With the contact form, this is only to confirm you have submitted successfully, it is not intended to block ‘“too many attempts”’.

So if you want to check the successful submission of ‘recover_customer_password’ form, you can follow my instructions or refer to Dawn theme’s code.

You can’t block the “too many attempts” message, it’s Shopify security.

Or you can contact Shopify for detailed explanation.

Hope it helps!

Does anyone have an answer for this? I would like to have multiple different contact forms on the same page but whenever any of them is submitted, contact_posted=true triggers all of them to show the success message.

Submitting a form will trigger all instances of form.posted_successfully on the page, regardless of what type of form they are. For example, on the Dawn contact page, if you submit the contact form, it will also trigger the newsletter subscribe below. I’ve talked to several theme developers about this and it’s a known issue.

1 Like