I have created a view that list media entities that are related to the module: Groups.

These documents have certain restrictions to them. Each document can get 1 of 4 permissions:

  1. Permission A
  2. Permission B
  3. Permission C
  4. Permission D

Users can get The same set of permissions per group. So i have to match the user, see if he is part of the group of the document and then check if he has the right permission within that group.

This is all working fine and went well with testing, but i have now run into the issue where if i have pagination in my view, it will check the permissions per page instead of on all the results, so page 1 can have 4 results and page 2 can have 15 and page 3 has 10.

I use the code below to show access denied for the user when he lands on the page:

function my_module_media_access($entity, $op, $account){
  $hasAccess = userHasMediaPermissions($entity);
  return AccessResult::forbiddenIf(!$hasAccess)

Is there a way to let the view check if the user can access the media entity in the HOOK_query_alter for example?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.