In Drupal 7, can I somehow remove the "delete"-link from the contextual menu?

Some users don't realize that this actually deletes the node. They think it only removes it from the current page but still exists in the database.


You can implement hook_menu_contextual_links_alter() to remove the "delete" link from the contextual links.

function YOURMODULE_menu_contextual_links_alter(&$links, $router_item, $root_path){

However, if your users are irresponsible enough to believe that "deleting" a node does not actually delete it, you may be better off simply removing those users' permissions to delete nodes at all.

  • I don't like this contextual link either. Easy to imagine someone thinking that it means delete from a view. – MrPaulDriver May 30 '18 at 22:18

After looking into Custom Contextual Links module, I found a way to do this.

function MYMODULE_contextual_links_view_alter(&$element, $items) {
    // Check if we have a node link to process
    if (isset($element['#element']['#node']->nid)) {

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.