Contextual Links add destination=node to URL - can i restrict that from happening? - stopping delete functionality I have a contextual link on a block that will take the user to an admin screen with a delete button on the admin screen.  The delete button works fine when not coming from the contextual link.  I noticed the contextual link adds "destination=node" to the end of the URL.  The fact that the contextual link adds that to the URL does not allow for my admin screen to redirect to the delete confirm admin screen.  If i remove the "destination=node" from the admin screen URL, it goes to the delete confirm admin screen with no issues.  Has anyone else had this issue?  I noticed this is for absolutely any module or block in drupal.  If going to the admin screen from a contextual link and it has a delete button on the admin screen, the delete functionality will not work!  Any suggestions?
The accepted answer is not entirely correct.  When hook_menu_contextual_links_alter() gets to act on the array of contextual links, no destinations have been set yet.

Instead, just a few lines after menu_contextual_links() (and so its alter hook) is called in contextual_pre_render_links(), there is this line adding the destination to the contextual link:

$item['localized_options']['query'] += drupal_get_destination();


If you set a query destination in hook_menu_contextual_links_alter(), the one you set will win.  But if you just want to get rid of the destination so for instance a redirect set in the form can do its thing (including, say, adding a fragment)... removing the destination before it is added here doesn't work.

This being Drupal, however, two lines later another alter hook is called:

drupal_alter('contextual_links_view', $element, $items);


(This is all in contextual module.)

So implement that hook instead.  For a module named example removing the destination from all node edit alter hooks on a given array of content type machine names available with the function example_selected_node_types(), the implementation would look like this:

/**
 * Implements hook_contextual_links_view_alter().
 */
function example_contextual_links_view_alter(&amp;$element, $items) {
  if (isset($element['#element']['#entity_type']) &amp;&amp;
      $element['#element']['#entity_type'] == 'node' &amp;&amp;
      in_array($element['#element']['#bundle'],
               example_selected_node_types()))
  {
    $element['#links']['node-edit']['query'] = array();
  }
}