1

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

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

Am I doing something wrong ?

2 Answers 2

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.

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;
        }
    }
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.