0

So I want to hide certain items if a user is not logged into the website. I already have a custom lightswitch field on each of the items but I'm not sure on how to write the code for it. Can anyone help?

Brad Bell
  • 67,440
  • 6
  • 73
  • 143

1 Answers1

3

Based on https://craftcms.com/docs/lightswitch-fields and https://craftcms.stackexchange.com/a/352/5134:

{% if entry.lightswitchFieldHandle %}
    {% if currentUser %}
        Display entry that only logged users can see
    {% endif %}
{% else %}
    Display entry that anyone can see
{% endif %}
Michael
  • 131
  • 3