Ecommerce Shopify WordPress Discussion

shopify redirect user after registration

i want my users to get a message that they have successfully signed up, once the process is completed, so i made a welcome page, but i cant redirect user to that page after they create an accont: this is the cutomer-register.liquid: <div class="sm:container"> <div class="customer-form"> {%- if section.settings.image != blank -%} {{- section.settings.image | image_url: width: section.settings.image.width | image_tag: loading: 'lazy', sizes: '50vw', widths: '300,400,500,600,700,800,1000,1200,1400', class: 'customer-form__image rounded' -}} {%- endif -%} <div {% render 'surface', class: 'customer-form__box', background_gradient: section.settings.background_gradient, background: section.settings.background, text_color: section.settings.text_color, background_fallback: 'bg-secondary' %}> <div class="customer-form__box-inner text-center"> <div class="v-stack gap-12"> <h1 class="h2"> {%- assign content = 'customer.register.title' | t -%} {%- render 'styled-text', content: content, gradient: section.settings.heading_gradient -%} </h1> <div class="v-stack gap-6"> {%- for block in section.blocks -%} {%- case block.type -%} {%- when '@app' -%} {%- render block -%} {%- when 'liquid' -%} {%- if block.settings.liquid != blank -%} <div {{ block.shopify_attributes }}> {{- block.settings.liquid -}} </div> {%- endif -%} {%- when 'fields' -%} <div {{ block.shopify_attributes }}> {%- form 'create_customer', class: 'form' -%} <div class="fieldset"> {%- if form.errors -%} {%- assign form_errors = form.errors | default_errors -%} {%- render 'banner', status: 'error', content: form_errors -%} {%- endif -%} {%- if request.locale.iso_code == 'ja' -%} {%- assign last_name_label = 'customer.register.last_name' | t -%} {%- render 'input', name: 'customer[last_name]', label: last_name_label, autocomplete: 'family-name', required: true -%} {%- assign first_name_label = 'customer.register.first_name' | t -%} {%- render 'input', name: 'customer[first_name]', label: first_name_label, autocomplete: 'given-name', required: true -%} {%- else -%} {%- assign first_name_label = 'customer.register.first_name' | t -%} {%- render 'input', name: 'customer[first_name]', label: first_name_label, autocomplete: 'given-name', required: true -%} {%- assign last_name_label = 'customer.register.last_name' | t -%} {%- render 'input', name: 'customer[last_name]', label: last_name_label, autocomplete: 'family-name', required: true -%} {%- endif -%} {%- assign email_label = 'customer.register.email' | t -%} {%- render 'input', type: 'email', name: 'customer[email]', label: email_label, autocomplete: 'email', required: true -%} {%- assign password_label = 'customer.register.password' | t -%} {%- render 'input', type: 'password', name: 'customer[password]', label: password_label, minlength: 5, autocomplete: 'new-password', required: true -%} {%- if block.settings.show_email_consent -%} {%- assign consent_label = 'customer.register.accepts_marketing' | t -%} {%- render 'checkbox', name: 'customer[accepts_marketing]', label: consent_label -%} {%- endif -%} </div> {%- assign submit_label = 'customer.register.submit' | t -%} {%- render 'button', content: submit_label, type: 'submit', size: 'xl', stretch: true, secondary: true, background: section.settings.button_background, text_color: section.settings.button_text_color -%} <div> <a href="{{ routes.account_login_url }}" class="link text-subdued">{{ 'customer.register.login' | t }}</a> </div> {%- endform -%} </div> {%- endcase -%} {% endschema %} i tried using this piece of code but it didnt work: <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); } })(); </script> any help would be appreciated, thanks
To ensure this code works, you need to: Set REDIRECT_PATH to the correct URL where you want to redirect users. Make sure that the form with the id create_customer or the form with the specified action and method attributes is present on your registration page. Ensure that the script is placed in the right location in your HTML code, typically just before the closing tag or in a place where it can run after the page has loaded. If you are still experiencing issues, you may want to check your browser's console for any JavaScript errors that could be preventing the script from running. Also, make sure that the liquid code is properly integrated into your Shopify theme.

December 30, 2023

Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.