Display Drupal menu local task tab according to node content type

By default every node should have the menu tab (MENU LOCAL TASK) of View and Edit.

If your module wants to add its own tab but only restricted to content type of “foo”, then use the following code snippet.

XYZ below is your page callback for the new custom tab. Basically it calls another function to validate user’s permission but we manipulate it to check the node type (via access callback )


* Implements hook_menu().


function YOUR_MODULE_menu() {

     $items = array();

     $items[‘node/%node/XYZ’] = array(


    ‘access callback’ => ‘YOUR_MODULE_access_check’,

    ‘access argument’ => array(1),

    ‘type’ => MENU_LOCAL_TASK,


return $items;


function YOUR_MODULE_access_check($node) {

  if( $node->type == ‘foo’ ) {

      return TRUE;


  return FALSE;



Remember to clear your Drupal caches at admin/config/development/performance after every change to your hook_menu above

Read more about hook_menu() here.

Sorry, I don’t know of easier way to explain this, let me know(comment on this) if you don’t understand.