I have a menu which has a block provided by the system automatically. This menu has links that come from a module which defines the menu(config). This menu block can be seen(ie. the block is visible) but it shouldn't be possible to attach another instance of this menu nor put links into it via UI. I do not want the admin so see this menu block in the list of available blocks on the block library page.

So far I have been able to tweak things so that some specific menus are not available for user to put links into or even see them in the menu listing(I have custom list builder for this + some form alterations in place). But when it comes to blocks the issue is that on some places Drupal checks plugin definitions(which are cached so I cannot distinguish if the user is on the "manage blocks" page or somewhere else or if the user has specific permissions and such) and in other places it uses the block entities.

So my question is how can I hide a block from the block library but keep the block displayed when attached to a region? If I remove the plugin definition the bloc kwon' be displayed since the plugin will be non existing. This works in other cases that I have but not int this one.

I think this relates to https://www.drupal.org/node/1975064 but I need to fix this ASAP.

1 Answer 1


So at the end my solution in regard to blocks was to create route access check for the block.admin_add route to prevent attaching unwanted blocks, override the controller for the block.admin_library route by extending the original one and removing unwanted blocks from the list, implementing hook_block_access to prevent certain operations on certain blocks and hook_block_filter to remove some blocks completely.

Your Answer

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