Shopify themes, liquid, logos, and UX
You can create a members-only store by showing a login or register page when customers navigate to your website. To make your store accessible only to registered customers, you need to edit your Customer accounts settings in the admin, and add some Liquid code to your theme.
Note: If you want only certain pages to be members-only, then you need to install an access management app from the Shopify App Store.
theme.liquid
.<head>
tag in the code. On a new line below the opening <head>
tag, paste the following code:{% unless customer %}
{% if template contains 'customers' or request.path == "/challenge" %}
{% assign send_to_login = false %}
{% else %}
{% assign send_to_login = true %}
{% endif %}
{% endunless %}{% if send_to_login %}
<meta content="0; url=/account/login?checkout_url=/" http-equiv="refresh" />
{% else %}
</body>
tag in the code. On a new line below the closing </body>
tag, paste the following code:{% endif %}
Customers that log in are automatically redirected to the home page of the shop. You can edit where customers are redirected by editing the meta refresh tag URL in the code you just pasted.
<meta>
tag in the file:<meta content="0; url=/account/login?checkout_url=/" http-equiv="refresh" />
checkout_url=/
. For example, if you want your logged-in customers to go to your catalog page when they navigate to your site, add collections/all
to the URL path. Your code should look like this:<meta content="0; url=/account/login?checkout_url=/collections/all" http-equiv="refresh" />
TyW | Online Community Manager @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
What would be the code if I wanted to restrict a specific site page to only logged in users with a specific tag?
Thanks for your help!
This should help: https://help.shopify.com/en/themes/liquid/objects/customer#customer-tags
Here is an example:
I also suggest disabling the account registration page, so people can't just create their own account and browse your store.
Stuck on how to do this if you could help.
Stuck at disabling the create an account page. I have everything else working, but I need to remove that page so I can get customers to email to request an account.
Just an Idea....
At the top of the page, add
{% if customer %}
At the Bottom of that area, add
{% endif %}
This will make it only show to people who are already logged in. Which ironically then won't show it because they are logged in so they do not need to create an account.
You can then make a section on the page, or a specific page with a Contact list about creating accounts. You can even set it up to TAG the customer as a Lead when they email you.
Best Regards.
Yes, the above method will work too.
The easiest solution for this is to go into your theme's code and copy the contents of the customers/login.liquid file and paste them/copy them over to the customers/register.liquid file. This will replace the registration page with a login form.
Good luck!
Hey there,
thank you for the short tutorial, works just fine. Now i need to find a solution so that anyone who registers needs to be activated by an admin first in order to see the shop. Any suggestions? Also, i'd like to add more forms to the registration process, maybe split it up into 3 pages because it's pretty much information. Also, is there a way to add a file upload option while registering? I need some documents from my customers before they're allowed to see the shop.
Have a nice day 🙂
Cedric,
You could use some basic liquid to only allow customers who have been tagged "Approved" access to the store. As for more forms/fields for registration the best solution we use is an app called customer fields: https://apps.shopify.com/customr
Thanks for your response Matt.
I already found exactly what i was looking for in this addon: https://apps.shopify.com/advanced-registration
Unfortunately, it is not available during shopify test phase which is sad. Is there any way to test it, without having to get a plan first?
Only some apps allow testing in a dev environment, seems like that one does not. I know the one I suggested will allow you to test it out.
I would like to know how to lock a collection only for logged in customers to see.
That's different topic, but you will find a tutorial how to do that here: https://www.youtube.com/watch?v=8Tsm8gkSK-o
Then you probably want to have a login page as homepage and no members-only store.
Hi TyW,
Thanks a lot for all this, I did the edits and it works perfect, the only issue is once the user has logged in, he is redirected to the My account page, while I have replaced the checkout URL with my homepage URL. This is weird, could you help me maybe?
My website is listd.ae and the password is listd
I attach the code below:
<head>
{% unless customer %}
{% if template contains 'customers' %}
{% assign send_to_login = false %}
{% else %}
{% assign send_to_login = true %}
{% endif %}
{% endunless %}
{% if send_to_login and request.path != "/challenge" %}
<meta content="0; url=/account/login?checkout_url=listd.ae/" http-equiv="refresh" />
{% else %}
Thanks a lot!
Hey all! Great tutorial. I have a little question (I might have overlooked and didn t see the answer already)
How can I have one page excluded from the only logged in customers can see content?
Like I want to display log in only when someone does not have an account yet but want to redirect "Create account" to an alternate page.
Can I somehow exclude the needed URL in the header part?
Hope you understand what I mean 😅
Thank you already!
Hi TyW,
The code works for me!
May I want to activate it for different pages of my site!
I explain:
- Client 1: will have the right to access my-domain/pages/1AC-GA (Page title: 1AC_GA)
- Client 2: will have the right to access my-domain/pages/2AC_GA (Page title: 2AC_GA)
I add to the client card 1, the tag: (1AC_GA)
And I add to the client card 2, the tag: (2AC_GA)
But it doesn't work! 🙂 🙂 🙂
I miss a code, to put on the (page.liquid)
Specific (page.1AC_GA.liquid) and (page.2AC_GA.liquid)
Please help!
Best regards.
User | RANK |
---|---|
235 | |
159 | |
60 | |
55 | |
47 |
Thanks to all who participated in our AMA with 2H Media on planning your 2023 marketing bu...
By Jacqui Mar 30, 2023Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023