Liquid, JavaScript, themes, sales channels
Currently the Shopify customer registration form, when successfully completed, redirects the user to the home page of the shopify website. This is unless there is an error in which case you are redirected to the registration form page and an error message displays. The final caveat is that if you have submitted the form already, there is a middle step of a google ReCAPTCHA challenge.
The problem we are experiencing is that no message displays alerting you you have successfully created an account.
We have been able to redirect the form back to the registration page on successful challenge using this code in the head block of our theme.liquid file:
<script> $(document).ready(function(){ var whereToRedirectAfterRegistering = '/account/register'; // Change this to tell Shopify where you want to redirect after registering. var registerForm = $('.shopify-challenge__button').parent(); // Register form, or captcha form for registering var formElement = $('<input type="hidden" name="return_to">'); // Make our element formElement.attr('value', whereToRedirectAfterRegistering); // Shopify will use this value as the redirect destination // formElement looks like <input type="hidden" name="return_to" value="/checkout" /> registerForm.append(formElement); // Add the element to the form. }); </script>
however the code that traditionally displays on success:
{%- if form.posted_successfully? -%} <p>Thank you for registering an account.</p> {%- endif -%}
...does not work.
Please Help!
Hi !
Did you find a solution ? I face the same issue !
Thanks in advance
form.posted-succesfully also did not work for me, but instead
{% if form.errors %}
worked.
Try do something like
{% if form.errors %} <h4>Register</h4> <p>Errors</p> {% else %} <h4>Register</h4> {% endif %}
Hope this helps.
I have tried all of the suggestions in the page without luck - I set my website as members-only and only customers that have been tagged as "approved" can login, meaning that when the user submits a form he is redirected to the login page (I don't know if this is affecting it) - can anyone help please?
<div class="customer__account-form text-center"> <div class="form-vertical"> {% form 'create_customer' %} <h1 class="h2">{{ 'customer.register.title' | t }}</h1> {% if form.posted_successfully? %} <h6> Thank you message <h6> {% else %} {{ form.errors | default_errors }} {% endif %}
Thank you!
Did anyone figure out a solution for this?
this is not working for me
Try adding the following code near the bottom of layout/theme.liquid, just before </body>. To redirect to a different page, simply replace “/checkout” with your desired redirect location... like a "thank you" page after form submission.
This code was written by our Customer Fields app developer team:
<script> (function() { var REDIRECT_PATH = '/checkout'; var selector = '#create_customer, form[action$="/account"][method="post"]', $form = document.querySelectorAll(selector)[0]; if ($form) { $redirect = document.createElement('input'); $redirect.setAttribute('name', 'return_to'); $redirect.setAttribute('type', 'hidden'); $redirect.value = REDIRECT_PATH; $form.appendChild($redirect); } })();
The Customer Fields app allows you to set a success message after form submission, set a static redirect path, or use rule logic to redirect to different paths based on form input.
Hope this helps!
Hi,
You can use this to change the redirect back to the registration page:
And for showing a succes message on the registration form. Because the customer automatically get's logged in when the registration form is success-full, you can simply check if they are logged-in:
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024