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
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 %}