Return to calling page after login

I would like some help from anyone familiar with shopify theme code.
I want to call their login page, and have it return to the calling page after login.
I see through google that shopify have provided and then dropped this functionality regularly over the last seven years.
In several cases they have provided a different search parameter for the return url, called:
return_url=
return_to=
redirect_to=
checkout_url=
when you call the login url ( currently /account/login used to be /customer_identity/login now a 404 error )
I am setting ALL of these, they are ignored.
I think the latest fix, until shopify change it again, is some complicated edit of the login form in the theme, to automatically return to the calling page after login, but I cannot find code that works.
BTW logOUT return works fine :slightly_smiling_face: using /account/logout?return_url=

Hey @kshepherd_1 ,

Have a look at this resource, it’ll redirect shopper to a specific location after login: https://www.revize.app/blog/customize-shopify-login-redirect-guide-for-new-customer-accounts

Hope this helps!

Cheers!
Shubham | Untechnickle

Thank you for your suggestion. I tested this just now, and it did not work.
I followed the guide that you linked, it says you need to search and replace all instances of:
{{ routes.account_login_url }}
and replace with:
{{ routes.storefront_login_url }}

in the theme code (I found three, in sections/registration-form.liquid line 89, snippets/mobile-menu.liquid line 51, snippets/header__action-icons.liquid line 63)
After entering my email address on the login screen, and then the 6 digit code emailed to me on the verify screen, I am redirected to /account/orders

Hey @kshepherd_1 ,

Can you DM or email us your collaborator code & store URL so that we can understand and fix this issue? That’d be great!

Looking forward to hearing from you,
Shubham | Untechnickle

Coding expert

Does anyone know the answer? None of the responses so far have been correct. I think the first one probably worked on an older version of shopify, but I do not think we can roll back.

This did work for me, I used this very basic structure for a protected page:

{% if customer %}
Yes Customer Logged In
{% else %}
Customer Not Logged In

{% endif %}

I was successfully redirected back to the referring page after logging in,