Redirect Login User to Previous Page (New customer accounts)

Is there a way to redirect users when they log in to the previous page they were on before they landed on the log in page?

We are using the New customer accounts:

6 Likes
  1. Online Store > Themes.
  2. Actions > Edit code.
  3. In the Templates directory, click customers/login.liquid or the file that contains the login code.
  4. Search for this line "{% form ‘customer_login’ %} "
  5. Below it, Paste this :

Replace the value in the above line with the page you want to display after login.

@Bhaskar_Sonowal

There is no login.liquid or anything close to that.

This is not a theme thing.

The url when one clicks “account” goes to “/account” and then redirects to this:
[https://customer.login.shopify.com/lookup?destination_uuid=1234&redirect_uri=https%3A%2F%2Fshopify.com%2F123%2Faccount%2Fcallback&rid=123&ui_locales=en-US](https://customer.login.shopify.com/lookup?destination_uuid=1234&redirect_uri=https%3A%2F%2Fshopify.com%2F123%2Faccount%2Fcallback&rid=123&ui_locales=en-US)

I am thinking I can try to hard-code the “account” url in the Header and adding the parameter redirect_uri.

1 Like

Just bumping this, I am also look for a solution where I can control the redirect on the New Account → Login screen.

We use YOTPO Loyalty and this New Account experience is extremely disruptive and confusing for customers since we can’t include any of our Reward information or language on the New Account page.

4 Likes

Any solution for this please?

3 Likes

I’m looking for this solution as well and cannot find the template mentioned in the theme either. I’m trying to find the right form in main-login.liquid, but am not sure if I’m looking at the right page and if the new vs. old account are even in the same place.

Did you end up finding a solution and if so, would you be willing to share it with this thread?

Thanks for any help!

I had confirmed by Shopify Support that redirecting back to the original page with NEW customer accounts is not supported. They duggested reverting back to classic.

2 Likes

Is it still the case?

Yes unfortunately I confirmed this a few days ago with support.

I reverted to using old accounts because of this - that’s the only solution/workaround at the moment.

Yeah makes sense. We’re using classic on our retail site, but our wholesale site uses Shopify’s b2b features which unfortunately require new customer accounts. Kinda stuck in a bad spot here at the moment. Please help Shopify

Same boat here, need the b2b features but want to redirect to the front page after logging in.

Shopify please do something…

I have created this solution for New Customer Accounts

Basically I am getting Last URL of non-login customers in browser session storage, and when they login with new Customer Account, after login the users initially redirected to Order Status Page, but from there when they click on Store the Home Page opens with accountnumber query Parameter,

shahidameen_0-1734037777699.png

so based on that I have created a following logic, and it redirect customers back to the paqe where they get to the login page

{% unless customer %}
 
{% endunless %}

,

Hey Shahidameen!

As far as I can understand, with your code the user is still directed to the account page after login, but then when going to the store he/she is redirected to the original page the came from before logging in - right?

My problem is I want the user to go straight to the front page of the store after login, so they don’t ever see the account page unless they actively choose to go there. I don’t think it is possible to add your script to the account page, which would be a way to solve this issue.

Not_guest_user_0-1734091187573.png

Try this and in retrun_to add your encoded return path

I am not sure what you mean, where should I create and use this URL?

you can replace the login URL with this (/customer_identity/login?return_to=) URL it will return the user after login to the given path

1 Like

Where can you modify the login URL when using the new Customer Accounts?

With Recent Shopify Release, you can just do that, either redirect them to Previous Page where login was originated and even to the Custom Page.

Here is the Change Log
https://changelog.shopify.com/posts/direct-customers-back-to-the-online-store-after-login

Credits: @Taylor Page

3 Likes

Hello @frede-1994

Now with Shopify Recent Release, you can just do that (Can be redirected back to the Previous Page from where login was originated) or to any custom page using

storefront_login_url route in the routes object.

Here is Change Log.

https://changelog.shopify.com/posts/direct-customers-back-to-the-online-store-after-login