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?

1 Answer 1

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 %}
1
  • How can I display the entry? Commented Aug 12, 2016 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.