Site access - Create a members-only store

TyW
Community Manager
Community Manager
435 50 1185

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)
vknggrl
Visitor
1 0 0

Hello!

First, thank you for this, it's been really helpful.

However, in the last week it's stopped working; customers just continue to get sent to the customer login page, even after login, and not to any other route. Is this code still working for you? Nothing changed code-wise from my end, so I'm wondering if something changed behind the scenes in shopify.

Thanks,

Phaedra

sonnybyrd
Visitor
1 0 0

This is awesome, thank you. How do you then customize / edit the log-in page that non-logged in users are directed to?

SteveOD
Visitor
1 0 0

Hey,

thanks for the tutorial. can you tell me how I can forward the other pages for logged in users? I don't want any user whether logged in or not, e.g. comes to the start page or collections. Only the checkout (BuyButton) and the user account should work. Many thanks

ALIAS
Visitor
2 0 0

how can you make the login page accept payment to create an account?

Somenfun
New Member
4 0 0

Hi Alias, did you ever figure this out? how can you make the login page accept payment to create an account?

Jrogers
Visitor
1 0 0

Hi there - I love your work here and it's very helpful.

I'm looking to use this but also allow customers to access only one other page via a link on this password/login page. I want them to submit an application to be a part of the member's only website. How do I give them access to only that one other page? Let me know if you have any questions.

michael-helium
Shopify Expert
316 3 148

@Jrogers if you're using Customer Fields I recommend reaching out to the support team via the in-app chat widget or by contacting support@heliumdev.com

To restrict access to a certain page you can hire a Shopify Expert to add some simple Liquid logic or use the Locksmith app. It would be easy enough to put a link in the customer's account page where they can access the member-only page after they've logged in. Our team also offers additional services exclusively for Customer Fields app users so you might consider that route as well.

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

checkout error

please help!!

Capture.PNG

HouseOfEnergy
Visitor
1 0 0

Hi if we only want a portion of our site (and it's products) to be a "Members Only Area" that requires registration + login (so we can capture emails and ensure they read our Members Area Terms & Conditions) –how would we do that?

[!] Requirements/Desires: 

  • All of site to be public EXCEPT "/membersarea" (has exclusive products, not available pubicly)
  • Anybody may register to become a member (must sign-up with email, sign terms and conditions)
michael-helium
Shopify Expert
316 3 148

@HouseOfEnergy 
If you're comfortable with Liquid, see this post.

If not, see our blog on this topic: How to Create a Shopify Membership Site and Restrict Access to Your Shopify Store

 

If you're already using Customer Fields for your members-only store, contact support@heliumdev.com.

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

How do I make my entire store paid subscription base? This run down helps with creating a member, but what if I want them to also sign up for a monthly or yearly membership?

lindsiejones
Visitor
2 0 0

Hello, when I go to the Customer accounts section, click Accounts are required: I do not have the same options as you have on here. Mine are attached. I need to have my site setup where people can't see anything past the homepage until they sign in to activate the other pages. **I apologize if this has been answered but I read a lot of the comments and did not find the answer. Thanks in advance 

lindsiejones_0-1675355852376.png

 

michael-helium
Shopify Expert
316 3 148

Hi @lindsiejones - Shopify announced new customer accounts on Jan 31. Looks like the settings have changed as well. That said, there is no way to lock down your store just by toggling Shopify settings. A Shopify Developer can help you with Liquid customization to prevent access to your site, or you could use an app. I wrote a blog about apps that can help you accomplish this. 

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

To be more precise, the setting to “require customer accounts” has been moved to Checkout settings. If you want to require all customers to login before checkout, from your Shopify admin, go to Settings > Checkout and select Require the customer to log in to their account before checkout from the Customer contact method section.

See screenshot: Image 2023-07-31 at 9.36.01 AM.png

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

Hello,

I cannot find this specific "Accounts required" customer accounts section in settings in the new Shopify summer edition. Is that possible?

michael-helium
Shopify Expert
316 3 148

@kengurugold 
The setting to “require customer accounts” has been moved to Checkout settings. If you want to require all customers to login before checkout, from your Shopify admin, go to 
Settings > Checkout and select Require the customer to log in to their account before checkout from the Customer contact method section.

Here's a screenshot:
Image 2023-07-31 at 9.36.01 AM.png


Source: https://heliumdev.com/blog/shopify-enable-customer-accounts

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