Answers.Body: <p>Based on <a href="https://craftcms.com/docs/lightswitch-fields" rel="nofollow noreferrer">https://craftcms.com/docs/lightswitch-fields</a> and <a href="https://craftcms.stackexchange.com/a/352/5134">https://craftcms.stackexchange.com/a/352/5134</a>:</p>
  
  <pre><code>{% if entry.lightswitchFieldHandle %}
      {% if currentUser %}
          Display entry that only logged users can see
      {% endif %}
  {% else %}
      Display entry that anyone can see
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-12T22:16:22.520Z
Answers.Text: How can I display the entry?
Answers.UserDisplayName: JustinTheeDude
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-09T21:01:19.273Z
Answers.LastActivityDate: 2016-08-09T21:01:19.273Z
Answers.LastEditDate: 2017-04-13T12:51:00.303Z
Answers.UserDisplayName: Michael
Body: <p>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?</p>
  
Tags: <lightswitch>
Title: Hiding specific items from public
ThreadText: # Hiding specific items from public
  
  (Asked by: username_0 on 2016-08-09)
  
  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?
  
  **Tags:** lightswitch
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-08-09. Score: 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 %}
  
  ```
  
  > **Comments:**
  > **username_0**: How can I display the entry?  
  
  ---
  
  