Create a members-only store

Caution

This is an advanced tutorial and is not supported by Shopify. Knowledge of web design languages such as HTML, CSS, Javascript and Liquid is required. We suggest hiring a Shopify Expert if you are not comfortable proceeding with the following tutorial.

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.

Enable customer accounts

  1. In the Customer accounts section, click Accounts are required:

    Customer accts req

  2. Click Save.

Edit your theme.liquid file

  1. Find the theme you want to edit, and then click Actions > Edit code.

  2. In the Layout directory, click theme.liquid.

  3. 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' %}
            {% 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 %}
    
    
  4. Find the closing </body> tag in the code. On a new line below the closing </body> tag, paste the following code:

    
    {% endif %}
    
    
  5. Click Save.

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

Customers that log in will be automatically redirected to the homepage 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.

Want to discuss this page?

Visit the Shopify Community