Site access - Create a members-only store

TyW
Community Manager
556 38 1001

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 42 (42)
MT-Sentissi
Excursionist
19 1 0

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!
kaan2
New Member
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

JessTurc
New Member
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

gsek2
New Member
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'. 

vknggrl
New Member
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
New Member
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?

CurtisB
New Member
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

SteveOD
New Member
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

mikeanwa
New Member
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
New Member
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!