Redirect to customer account page after login

I have a full page extension that I want to redirect customers to after login.

I figured I could do something like:

<a href="/customer_authentication/login?return_to={{ routes.account_url | append: '/pages/<extension ID>' | url_encode }}">
  Log in
</a>

This doesn’t seem to work and instead sends the user to the orders page. The docs say that it can only handle redirects to the “online store”, which makes sense, but I feel like this should be an option.

1 Like

Hi Kyle,

I feel that this may be intentional behaviour, but let me doublecheck with the customer account extensibility team.

2 Likes

Hey Kyle, here are the docs on how to link to a specific full page extension.

@Kenza_Iraki, just to clarify, we have already tried using this method which works if a customer is already logged in, but does not seem to work for redirecting customers after login. Can you confirm if that’s the expected behavior or if there’s something we’re missing here? Thanks!

We have specifically tried all of the following:

<a href="{{ routes.account_url }}/pages/extensionId">Account Extension</a>

<a href="{{ routes.account_login_url }}/pages/extensionId">Account Extension</a>

<a href="/customer_authentication/login?return_to={{ routes.account_url | append: '/pages/extension ID' | url_encode }}"> Log in</a>

You’re right, the docs are wrong here, because routes.account_url contains query params, making the resulting url invalid. We’ll look at improving this. In the meantime, you can either:

  • Link to your full page extension directly via the online store header menu links (Admin → Content → Menus)
  • Strip the query params out of routes.account_url, add the path to your full page extension, and then append the query params back at the end. Example liquid code:
{% assign url_parts = routes.account_url | split: '?' %}
{% assign base_url = url_parts | first %}
<a href="{{ base_url }}/pages/extensionId{% if url_parts.size > 1 %}?{{ url_parts.last }}{% endif %}">Account Extension</a>
1 Like

Thanks for the follow up @Kenza_Iraki! I’ll make sure our team is aware of this :smile:

Hey, thanks for taking the time to post relevant documentation as well as those corrections. We are familiar with the issue regarding the query params, we ended up just doing something like:

{% assign account_page_path = '/account/pages/' | append: app.metafields.extensions.full_page_extension_id %}

{% assign button_href = routes.account_url | replace: '/account', account_page_path %}

<a href="{{ button_href }}">Log in</a>

Everything is working now as expected. I swear I already tried linking directly to the full page extension even if the customer isn’t logged in, and was just getting redirected to the orders page after login. But I suppose either something got fixed, or more likely, I just wasn’t doing something right.

Either way, things are looking good, and thanks again.

2 Likes