Skip to main content
3 of 7
added 179 characters in body
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.

For example content editors you gave permission to administer content are also allowed to update blocks of your custom block plugin:

/**
 * 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::allowedIfHasPermission($account, 'administer nodes');
  }
  return AccessResult::neutral();
}

You also need to alter the form not to redirect on submit to a page the user has no access to.

4uk4
  • 101.7k
  • 7
  • 173
  • 217