Remove the "translate" contextual link, when user does not not have the edit permission for this node.

Public

</> CopyGet raw version
php
  1. /**
  2.  * Implements hook_menu_contextual_links_alter().
  3.  */
  4. function MY_MODULE_menu_contextual_links_alter(&$links, $router_item, $root_path) {
  5. global $user;
  6.  
  7. if ($root_path == 'node/%') {
  8. // Remove the "translate" links, when user does not not have the edit permission for this node.
  9. $node = $router_item['page_arguments'][0];
  10. if (!node_access('update', $node, $user)) {
  11. unset($links['node-translate']);
  12. }
  13. }
  14. }