<p>If you are faced with such a task, then I think it's better to use user IDs, getting from the method a <code>ids</code> from the field in which users are stored, and check the received array using the <code>in</code> method. Another option is a plugin <a href="https://plugins.craftcms.com/user-group-field" rel="nofollow noreferrer">https://plugins.craftcms.com/user-group-field</a>.</p>
<pre><code> {% set usersIds = entry.usersField.ids %} 

    {% if currentUser.id in usersIds %} 
        Show the page
    {% else %}
        Permission Denied
    {% endif %}
</code></pre>

CC BY-SA 4.0
2020-07-16T08:11:22.977Z
Perfect! Exactly what I was looking for. Appreciate it.
revlis
CC BY-SA 4.0
2020-07-16T07:11:52.930Z
2020-07-16T07:11:52.930Z
Pavel Pavlovich
<p>I would like to restrict entries to specific users on the frontend via a User Field called userSelector. It should be possible to have more than 1 user. I understand groups might work, but I feel like it's easier to just select the user(s) directly on the entry.</p>
<p>I know the code below won't work, but hopefully, it shows my intentions a bit more.</p>
<pre><code>{% set users = entry.userSelector.all() %}
{% if currentUser.email == users.email %}
    Show the page
{% else %}
    Permission Denied
{% endif %}
</code></pre>
<p>Very open to other suggestions.</p>

<craft3><users>
Restrict entries to specific users
# Restrict entries to specific users

(Asked by: username_0 on 2020-07-16)

I would like to restrict entries to specific users on the frontend via a User Field called userSelector. It should be possible to have more than 1 user. I understand groups might work, but I feel like it's easier to just select the user(s) directly on the entry.
I know the code below won't work, but hopefully, it shows my intentions a bit more.
{% set users = entry.userSelector.all() %}
{% if currentUser.email == users.email %}
    Show the page
{% else %}
    Permission Denied
{% endif %}

Very open to other suggestions.

**Tags:** craft3, users

---

## 1 answers

### Answer by username_1 on 2020-07-16. Score: 3 | Accepted answer

If you are faced with such a task, then I think it's better to use user IDs, getting from the method a ids from the field in which users are stored, and check the received array using the in method. Another option is a plugin https://plugins.craftcms.com/user-group-field.
 {% set usersIds = entry.usersField.ids %} 

    {% if currentUser.id in usersIds %} 
        Show the page
    {% else %}
        Permission Denied
    {% endif %}

> **Comments:**
> **username_0**: Perfect! Exactly what I was looking for. Appreciate it.  

---

