*Help* - Restricting access to logged in users for specific pages

Highlighted
Tourist
8 0 2

Hi,

I have 3 pages that I want to restrict access to, so that only customers who are logged in can access. I've found the guide here to restrict access to the whole site https://help.shopify.com/themes/customization/access/create-members-only-store and I'm trying to amend so that customers are only prompted to login if they try to access these 3 pages and they are not already logged in.

I'm using the below code but it is still asking for a login for all pages, where have I gone wrong?

Pasted under <head> tag:

{% unless customer %}

    {% if template contains 'customers' %}

        {% assign send_to_login = false %}

    {% else if page.handle = ‘budget-planner’ or page.handle = ‘planning-checklist’ or page.handle = ‘guest-list' %}

        {% assign send_to_login = true %}

    {% endif %}

{% endunless %}

{% if send_to_login %}

<meta content="0; url=/account/login?checkout_url={{ shop.url }}" http-equiv="refresh" />

{% else %}

... Other theme.liquid contents here ...

Pasted below </body> tag:

{% endif %}

0 Likes
Tourist
22 0 2