How to Stop redirecting to /account after login?

shoppohs
New Member
1 0 0

We are looking to have the the user redirect to the home page once they log in. Currently they are redirected to the page /account

According to this article (https://help.shopify.com/themes/customization/customer-pages/redirect-customers-when-they-log-in ) you simply add the following line:

 <input type="hidden" name="checkout_url" value="/index" />

directly below the line:

 {% form 'customer_login' %} section of the customers/login template page

 

We don't see a customers/login page, but we have a customers/login.liquid page. So we added that line and can see it if we view source on the log in page. But it doesn't work, once you log in it goes to the /account page.

 

Any ideas?

 

Replies 9 (9)
Milan_Balaban
Shopify Partner
1 0 0

Rather than stopping, simply redirect. This simple script on account page should do the trick:

<script>
  if(document.referrer == 'login page ') document.location = 'page you want to go'
</script>

Naturally, substitute the pages. It will only work coming from the login page

Steven_Chu
Shopify Expert
12 0 4

Hi all! I just figured it out - it's {{ canonical_url }}

<meta content="0; url=/account/login?checkout_url={{ canonical_url }}" http-equiv="refresh" />

Stores I built: Flora1761.com (highly art-directed Nail Lacquer boutique) / Marissa-Webb.com (NYC SoHo Fashion Brand) / ViraniJewelers.com (high-volume product jewelry website) / Chuubie.com (my personal testing ground, using Shopify CMS as a stock photography sales platform)
Ariel_Estrin
Excursionist
15 0 6

Hey Steven Chu i'm having same problem as you.

I'm using :

<script>
  if(document.referrer === "https://www.smokingbetter.com/account/login"){
    history.go(-2);
  }
</script>

but first it displays the account page and after a short delay it returns to the requested page.

is your fix working instant without displaying the account page?

where did do you put that code?

thanks for the help.

Steven_Chu
Shopify Expert
12 0 4

Hi there. You don't need that script.

See my answer here!: https://ecommerce.shopify.com/c/ecommerce-design/t/solution-members-store-redirect-back-to-current-p...

Stores I built: Flora1761.com (highly art-directed Nail Lacquer boutique) / Marissa-Webb.com (NYC SoHo Fashion Brand) / ViraniJewelers.com (high-volume product jewelry website) / Chuubie.com (my personal testing ground, using Shopify CMS as a stock photography sales platform)
Ariel_Estrin
Excursionist
15 0 6

well it keep refreshing the page non stop. where did you include that line?

 

Ariel_Estrin
Excursionist
15 0 6

 *** double reply by mistake  ***

medmedishere
New Member
1 0 0

This may help you : 

Redirect customer on login

  • From your Shopify admin, go to Online Store > Themes.
  • Find the theme you want to edit, and then click Actions > Edit code.
  • In the Templates directory, click customers/login.liquid.
  • Find the following line of code:

 

{% form 'customer_login' %}​

 

On a new line below it, paste the following:

 

 

 

<input type="hidden" name="checkout_url" value="/collections/all">

 

 

 

 

 

$(document).ready( function() {
  $('a[href^="/account/logout"]').on("click", function() {
    $.ajax( $(this).attr('href') )
      .done(function() {
        // Here you will change the url to whatever page you want to redirect to
        window.location.href = "/collections/all";
      });
    return false;
  });
});

 

 

 

 

Redirect customer on new account creation

 

By default, the new customers are directed to the account page after register new account. Kindly follow the below steps to redirect the customer to a specific page when they register new account:

 

  • From your Shopify admin, go to Online Store > Themes.
  • Find the theme you want to edit, and then click Actions > Edit code.
  • In the Templates directory, click customers / register
  • Find the following line of code

 

 

 

{% form 'create_customer' %}

 

 

 

On a new line below it, paste the following:

 

 

<input type="hidden" name="return_to" value="/collections/all">

 

 

 

 

  • For the value attribute in the line of code that you just pasted, replace /collections/all with the relative URL of the page that you want customers to see when they register new account.
  • Click Save
Interiortech
New Member
1 0 0

the above redirect code to home page is not working for my theme. Is it specific to a theme?

Outlineind
New Member
1 0 0

I have made this work for the account login page, but need a solution for the "account activation" is there a similar code that can make this work?