Site access - Create a members-only store

TyW
Community Manager
Community Manager
435 50 1182

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.

 

Enable customer accounts

  1. From your Shopify admin, go to Settings > Checkout.
  2. In the Customer accounts section, click Accounts are required:

    members-01.jpg

  3. Click Save.

Edit your theme.liquid file

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, and then click Actions > Edit code.
  3. In the Layout directory, click theme.liquid.
  4. Find the opening <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 %}
  5. Find the closing </body> tag in the code. On a new line below the closing </body> tag, paste the following code:

    {% endif %}
  6. Click Save.

Change the page that logged-in customers are redirected to (optional)

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.

  1. Find the following <meta> tag in the file:

    <meta content="0; url=/account/login?checkout_url=/" http-equiv="refresh" />
  2. Add the URL path you'd like to use just after 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" />
  3. Click Save.

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

Replies 50 (50)
Ryanf153
Visitor
1 0 0

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!

martinhalik
Excursionist
32 0 18

This should help: https://help.shopify.com/en/themes/liquid/objects/customer#customer-tags

 

Here is an example:

{% for tag in customer.tags %}
  {% if tag contains 'newsletter' %}
     Show Heyyy! Your are customer with tag including word newsletter
  {% endif %}
{% endfor %}
michaelh730
Visitor
1 0 1

How do I edit the code to require customers to register / login on the shopping (product page) only? I want the rest of the website open to anyone, but I need to require customers to login or register in order to view the "Shop / Product Collection" Page of my website. I would rather edit the code to make this change versus paying a monthly subscription fee for an access management app. 

 

Thanks,
Mike 

michael-helium
Shopify Expert
315 3 148

@michaelh730 check out this post which shows how to determine whether a customer is logged in or not. It shouldn't be much more work than that to redirect the customer to register/login. If you're not comfortable with Liquid use the Locksmith app or hire a Shopify Expert to code this in for you. 

Michael, COO @ Helium
- Customer Fields ✪✪✪✪✪ (321 reviews)
- Meteor Mega Menu ✪✪✪✪✪ (243 reviews)
vtpokecards
Visitor
1 0 0

This is exactly what I want do to. I have made my page member only access, but I want it to be only if you have a certain tag. Where do I insert the coding you @martinhalik  mentioned 

{% for tag in customer.tags %}
{% if tag contains 'savage' %}
Well well well...
{% endif %}
{% endfor %}

 

Thank you!

 

 

martinhalik
Excursionist
32 0 18

Not remember exactly but you can put it on specific page template you want to restrict. Or for whole store you can put it in theme.liquid around {{ content_for_layout }}

 

You will see what it does and then you can proceed based on that.

Here is something similar with demo https://www.youtube.com/watch?v=oNegu1CmV64

Hope it helps.

Voltage_Matt
Shopify Expert
54 0 22

I also suggest disabling the account registration page, so people can't just create their own account and browse your store. 

BerserksGlass
Tourist
4 0 0

Stuck on how to do this if you could help.

Voltage_Matt
Shopify Expert
54 0 22

Where are you stuck?

BerserksGlass
Tourist
4 0 0

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.

Reincarnated
Pathfinder
103 8 35

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.

Voltage_Matt
Shopify Expert
54 0 22

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!

BerserksGlass
Tourist
4 0 0

Thank you. Got it working now.

CedricLBK
Visitor
2 0 0

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 🙂

Voltage_Matt
Shopify Expert
54 0 22

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 

CedricLBK
Visitor
2 0 0

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?



Voltage_Matt
Shopify Expert
54 0 22

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. 

shopshoesbyty1
Visitor
1 0 0

I would like to know how to lock a collection only for logged in customers to see.

martinhalik
Excursionist
32 0 18

That's different topic, but you will find a tutorial how to do that here: https://www.youtube.com/watch?v=8Tsm8gkSK-o

kantankaJewels
Visitor
2 0 0

How would you add the "approved" tag to customers?

 

where would you see the new customer registrations to approve them?

 

Right now i have a registration page that allows people to sign up and automatically browse after signing up. I'd like to approve them before they're allowed to browse the store, after uploading some identifying documents.

michael-helium
Shopify Expert
315 3 148

There are two distinct problems mentioned on this thread:

  1. Collecting additional information from customers in order to approve their account as a wholesaler
  2. Locking unauthorized customers out of certain parts of the storefront (products/pricing, collections, navigation items, etc.)

Collecting customer information

You'll most likely need to use an app like Customer Fields (see this post about why an app is required to store data to a customer account on Shopify.)

Customer Fields enables you to:

  • create unique registration form(s) 
  • collect important information from customers
  • organize/segment customers
  • manage customer tags

All of these are important steps in the process of approving new wholesale customers and restricting unauthorized access to wholesale products or pricing.

Locking unauthorized customers out

To restrict access to your store, you will either need to follow the tutorial on this thread or use an app like Locksmith. There are many guides (such as this one) that demonstrate how to hide products/collections using Liquid code (usually based on customer tags), but no code solution is "one size fits all".

This is why we recommend using the Locksmith app; it's a powerful and flexible tool specifically built for access control.

Here's a snapshot into an ideal flow used by many wholesale merchants:

  1. Use Customer Fields to create unique registration form(s) to collect important information from your wholesale customers
  2. Enable account approval so you can review/approve customers before an account is created on Shopify
  3. Automatically tag customers (eg: “B2B”) who complete your wholesale registration form (if using account approval, the tags are added to Shopify after customers are approved)
  4. Use Locksmith to restrict access to the entire store, certain products, collections, menu items, etc. based on customer tags

Keep in mind that the flow above is just one example -- there are lots of other use-cases and flows that can be handled as well!

Michael, COO @ Helium
- Customer Fields ✪✪✪✪✪ (321 reviews)
- Meteor Mega Menu ✪✪✪✪✪ (243 reviews)
michael-helium
Shopify Expert
315 3 148

@kantankaJewels 

The account approval and auto-tagging features of the Customer Fields app sound like a perfect solution for you.

Michael, COO @ Helium
- Customer Fields ✪✪✪✪✪ (321 reviews)
- Meteor Mega Menu ✪✪✪✪✪ (243 reviews)
kaan2
Visitor
1 0 0

Hey,

I am working on developing a members-only store.  I have noticed that you solved that issue. Can you help me out for that please if possible ?  I can also make you payment if you can set up same thing for my store

gsek2
Visitor
1 0 0

If I were to configure the coding for Login so that the option to 'Create Account' is no longer there by deleting:

<p>
{{ 'layout.customer.create_account' | t | customer_register_link }}
</p>

 

Would that interfere with me sending out Account invitations for customers I want to have access to my website?

I did try to send out an account invite as a test run; however, upon clicking the link to activate account it comes up as 'refused to connect'. 

kantankaJewels
Visitor
2 0 0

i've done this but now when i try to click create an account nothing happens. 

 

When i disable customer accounts the main page doesn't even load. in order to make the main page load i've enabled customer accounts but noting happens when i click create an account. 

 

how do i get customers to request an account?

 

 

i've copied the contents of customers/login.liquid over customers/register.liquid effectively removing the original content of customers/register.liquid.

 

 

how do i get customers to request an account?

mikeanwa
Visitor
2 0 0

Hi,

how to stop customers on the member-only page to just sign in and log in to the collection page?

ALIAS
Visitor
2 0 0

How do you integrate this? I am trying to create a  subscription page but the login already has the payment options so they must pay to enter the site. Can someone help me with this? Please!!! 
Thank you!

afp1978
Visitor
2 0 0

I like your idea of disabling account sign ups from the landing page. I would like to keep my store invite only to start so I would like to disable the create account link on the home page lander. Do you know how to do that?

martinhalik
Excursionist
32 0 18

Then you probably want to have a login page as homepage and no members-only store.

julient
Tourist
18 0 3

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! 

lamettav
Visitor
1 0 0

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!

MT-Sentissi
Excursionist
22 1 2

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.

 

@MT-Sentissi
- Click Like to let me know, if my Reply was helpful!
- "Accept as Solution" if my comments were a help to your question!
JessTurc
Visitor
1 0 0

Hi Guys,

I have put the coding into my FLOW theme, however it doesn't allow me to access to customise my theme anymore in the editor?

Is this something extra that I need to look into? I have copied the coding straight from this forum.

Thank you in advance,

Jessica

CurtisB
Visitor
2 0 1

Hi @JessTurc, did you figure out how to get the editor to work again?  I had the same issue after putting the login page code in place. 

Thanks,

CurtisB