Answers.Body: <p>Not sure if you can hide the entry in the CP just based on the user group... likely you'll have to separate those entries em distinct sections to do so.</p>
  <p>Another approach, would be allow them to see then entry, but not make changes using <code>EVENT_BEFORE_SAVE</code> and a field to store the groups allowed to edit i.e. <code>userGroup</code></p>
  <pre><code>Event::on(
      Entry::class,
      Element::EVENT_BEFORE_SAVE,
      static function(ModelEvent $event) {
          /** @var Entry $entry */
          $entry = $event-&gt;sender;
  
          $groups = $user = Craft::$app-&gt;getUser()-&gt;getIdentity()-&gt;getGroups();
  
          if (!in_array($entry-&gt;userGroup, $groups)) {
              $entry-&gt;addError('userGroup', 'Not allowed...');
              $event-&gt;isValid = false;
          }
      }
  );
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-05-26T16:21:36.687Z
Answers.LastActivityDate: 2024-05-26T16:21:36.687Z
Answers.UserDisplayName: Leo Leoncio
Answers.Body: <p>The &quot;Current User Condition&quot; evaluates attributes on the <em>current user</em> editing the entry – so having <code>Slug equals poi-1</code> in there isn't right as the slug to evaluate is on the <em>entry</em>, not the user.</p>
  <p>To fix that, you need to delete the <code>Slug equals poi-1</code> rule from the &quot;Current User Condition&quot;, and create it below the &quot;Entry Condition&quot; section instead.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-05-24T13:56:07.480Z
Answers.LastActivityDate: 2024-05-24T13:56:07.480Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>I have somes entries :</p>
  <ul>
  <li>POI-1</li>
  <li>POI-2</li>
  <li>POI-3</li>
  </ul>
  <p>I have two groups of users :</p>
  <ul>
  <li>Group-1</li>
  <li>Group-2</li>
  </ul>
  <p>Needs :</p>
  <ul>
  <li>The Group-1 can edit only POI-1</li>
  <li>The Group-2 can edit only POI-2 and POI-3</li>
  </ul>
  <p>I see that I can set this kinds of conditions only to Tabs and Fields.</p>
  <p>I tried on Tabs like this but not working :
  <a href="https://i.sstatic.net/195lohK3.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/195lohK3.png" alt="enter image description here" /></a></p>
  <p>I should see at least Tab of POI-1 with user from Group-1. I got this results for all entries when trying to edit it :</p>
  <p><a href="https://i.sstatic.net/UmkNzk0E.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/UmkNzk0E.png" alt="enter image description here" /></a></p>
  <p>Am I doing something wrong ?</p>
  
Tags: <craft4><admin><conditional><dashboard>
Title: Craft 4.8.0 : Hide some entries to a group of user
ThreadText: # Craft 4.8.0 : Hide some entries to a group of user
  
  (Asked by: username_0 on 2024-05-24)
  
  I have somes entries :
  
  * POI-1
  * POI-2
  * POI-3
  
  I have two groups of users :
  
  * Group-1
  * Group-2
  
  Needs :
  
  * The Group-1 can edit only POI-1
  * The Group-2 can edit only POI-2 and POI-3
  
  I see that I can set this kinds of conditions only to Tabs and Fields.
  
  I tried on Tabs like this but not working :
  [![enter image description here](https://i.sstatic.net/195lohK3.png)](https://i.sstatic.net/195lohK3.png)
  
  I should see at least Tab of POI-1 with user from Group-1. I got this results for all entries when trying to edit it :
  
  [![enter image description here](https://i.sstatic.net/UmkNzk0E.png)](https://i.sstatic.net/UmkNzk0E.png)
  
  Am I doing something wrong ?
  
  **Tags:** craft4, admin, conditional, dashboard
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2024-05-26. Score: 1
  
  Not sure if you can hide the entry in the CP just based on the user group... likely you'll have to separate those entries em distinct sections to do so.
  
  Another approach, would be allow them to see then entry, but not make changes using `EVENT_BEFORE_SAVE` and a field to store the groups allowed to edit i.e. `userGroup`
  
  ```
  Event::on(
      Entry::class,
      Element::EVENT_BEFORE_SAVE,
      static function(ModelEvent $event) {
          /** @var Entry $entry */
          $entry = $event->sender;
  
          $groups = $user = Craft::$app->getUser()->getIdentity()->getGroups();
  
          if (!in_array($entry->userGroup, $groups)) {
              $entry->addError('userGroup', 'Not allowed...');
              $event->isValid = false;
          }
      }
  );
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2024-05-24. Score: 1
  
  The "Current User Condition" evaluates attributes on the *current user* editing the entry – so having `Slug equals poi-1` in there isn't right as the slug to evaluate is on the *entry*, not the user.
  
  To fix that, you need to delete the `Slug equals poi-1` rule from the "Current User Condition", and create it below the "Entry Condition" section instead.
  
  
  ---
  
  