Skip to main content
1 of 7
4uk4
  • 101.7k
  • 7
  • 173
  • 217

If a user doesn't have the admin permission for an entity type this doesn't mean you can't allow the user specific operations on specific existing entities:

/**
 * Implements hook_ENTITY_TYPE_access() for entity type "block".
 */
function mymodule_block_access(\Drupal\block\Entity\Block $block, $operation, \Drupal\Core\Session\AccountInterface $account) {
  if ($operation == 'update' && $block->getPluginId() == 'custom_block_plugin_id') {
    return AccessResult::allowed();
  }
  return AccessResult::neutral();
}
4uk4
  • 101.7k
  • 7
  • 173
  • 217