- Issue created by @lincoln-batsirayi
- π§πͺBelgium lobsterr
Hi, you need to check if user has permission "view group_term:tags entity" (in this case I have tags taxonomy vocabulary enabled as a plugin in my group type). You can do it like this:
$group->hasPermission('view group_term:tags entity', $account);
The same way you can check any other permissions like edit, delete:
$group->hasPermission('update any group_term:tags entity', $account);
- π¬π§United Kingdom lincoln-batsirayi
Hi @lobsterr thanks for the reply, so yes i can confirm that this works when checking against the actual group entity, but Iβd like to do this check against one of the taxonomy tags for example.
So through the following
$group_relationships_tags = GroupRelationship::loadByPluginId('group_term: tags');
i can get a list of all the relationship entities, in the resulting array i can see that a relationship does exist which connects that individual taxonomy term to the group.
I was wondering if it's possible to get more specific and do the access check based on those individual terms?
- π§πͺBelgium lobsterr
I think you are looking for this method 'loadByEntity' :
This an example how you can use it.
$group_relationships = GroupRelationship::loadByEntity($term); foreach($group_relationships as $group_relationship) { $group = $group_relationship->getGroup(); if ($group->hasPermission('view group_term:tags entity', $account)) { // Do something here. } }
- π¬π§United Kingdom lincoln-batsirayi
Ok great! I was able to make it work this way, thanks so much for your help @lobsterr