I'm trying to alter custom blocks contextual menu. In particular I need to remove "Configure block" and "Delete". Is there any way to achieve this?

bumped to the homepage by Community yesterday

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


You can by adding this to your theme's css file.


.block-contentblock-delete { 
  display: none; 

The correct way to alter contextual links is to use hook_contextual_links_alter.

In your case, it should look something like:

function my_module_contextual_links_alter(array &$links, $group, array $route_parameters) {
  if ($group === 'block') {
    // Hide Configure Block option.

The contextual links are heavily cached in the browser, therefore you need to make sure that the browser session cache is cleared - window.sessionStorage.clear(); - source.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.