We'll be discussing a customization needed by many vendors for their online stores. Typically, when you log into your store account, you are redirected to the account page by default.
Why to change redirect URL from account?
Suppose you have a special category product in your Shopify store, and you want customers to be redirected to this category after logging in, instead of the account page. This change can enhance user interaction by simplifying navigation and reducing effort for the customer.
How to change redirect URL?
First go to your Shopify admin panel and create a duplicate of your live theme to avoid disruptions. Then, edit the code for the login and registration pages.
Even if you lack coding knowledge, you can follow these steps.
Change URL for Login page
Search for file named main-login.liquid in the code editor.
Search for below code
{%- form 'customer_login', novalidate: 'novalidate' -%}
Now add a hidden type field under the Customer Login form object. Insert the URL where you want users to be redirected post-login. For instance, if you enter "cart" as the URL value, users will be redirected to their cart page instead of the account page after logging in.
Paster the below code to enable the feature.
<input value="/cart" name="checkout_url" id="checkout_url" type="hidden">
Test the changes by logging out and logging back in to see if the redirection works as intended.
Similarly, you can modify the registration page to redirect users to a specific page or collection post-registration.