Understanding form.posted_successfully

New Member
1 0 0

Could someone explain exactly how the form.posted_successfully function works?

I am trying to trigger a register user event, however when clicking on “submit”, I am unable to verify that the form was indeed successfully submitted. For example, I tried adding the following code snippet within the relevant form in customers/register.liquid:

{%- if form.posted_successfully? -%}
<script>console.log("check if submitted");</script>
{%- endif -%}


However, nothing happened when I was added as a user since I couldn’t see a message in the console. Could you please guide me as to how the output of this function should look like? Or alternatively, how to trigger an event on the client’s side once a user was successfully added (server side).

Shopify Partner
455 80 98

Did you put that code inside form ? It should work, it will not work if you put it outside of {% form .... %}

Author: Hovhannes Sargsyan (aka sarhov).
An individual web developer focused on Shopify development.
Need more help? Feel free to send me a direct message or drop an email shopify@sarhov.com

Website: https://sarhov.com  
Email: shopify@sarhov.com
Skype: @sarhov
Messenger: @sarhov
Telegram: @sarhov