<p>Craft has a handy <code>{% requireLogin %}</code> <a href="https://craftcms.com/docs/templating/requirelogin" rel="nofollow noreferrer">tag</a>; this seems like the quickest and easiest solution for you.</p>

<p>If this particular entry has its own Twig template you can just put this tag at the top of the file.</p>

<p>Alternatively, as you say you could create a lightswitch field, add that to your entry type and simply tick the entries you would like to be password protected.</p>

<p>A simple piece of Twig code that checks the lightswitch and does what you need could look like this:</p>

<p><code>{% if entry.requireLogin %}
    {% requireLogin %}
{% endif %}
</code></p>

CC BY-SA 3.0
2016-11-19T16:27:46.487Z
This got me there. I ended up using {% if entry.lightswitchhandle == false or (currentUser and currentUser.can('accessCp')) %} in the navigation setup as a conditional so it would not show pages that are restricted to administrators instead of showing them and requiring a login next. I did insert the requireLogin in the entry page of course :-)
noregt
CC BY-SA 3.0
2016-11-18T15:42:55.883Z
2016-11-18T15:42:55.883Z
Jamie Wade
<p>I tried 'draft page' but that only shows it in live preview. I need it accessible through the navigation as well. I was expecting a concept button in the CP that would allow this?</p>

<p>Do I need to make a specific light switch and create conditionals or is there some logic in the system?</p>

<control-panel><editing>
How can I make an entry (in this case a page from structure) only visible to users with cp access?
# How can I make an entry (in this case a page from structure) only visible to users with cp access?

(Asked by: username_0 on 2016-11-18)

I tried 'draft page' but that only shows it in live preview. I need it accessible through the navigation as well. I was expecting a concept button in the CP that would allow this?

Do I need to make a specific light switch and create conditionals or is there some logic in the system?

**Tags:** control-panel, editing


---

## 1 answers

### Answer by username_1 on 2016-11-18. Score: 3 | Accepted answer

Craft has a handy `{% requireLogin %}` [tag](https://craftcms.com/docs/templating/requirelogin); this seems like the quickest and easiest solution for you.

If this particular entry has its own Twig template you can just put this tag at the top of the file.

Alternatively, as you say you could create a lightswitch field, add that to your entry type and simply tick the entries you would like to be password protected.

A simple piece of Twig code that checks the lightswitch and does what you need could look like this:

`{% if entry.requireLogin %}
{% requireLogin %}
{% endif %}`

> **Comments:**
> **username_0**: This got me there. I ended up using {% if entry.lightswitchhandle == false or (currentUser and currentUser.can('accessCp')) %} in the navigation setup as a conditional so it would not show pages that are restricted to administrators instead of showing them and requiring a login next. I did insert the requireLogin in the entry page of course :-)  

---

