I am trying to hide node "edit" tab for certain content types and roles without removing or disabling access to the edit pages. An edit button is going to be created manually and displayed on node pages.
Used below snippet but it disables access to the edit pages too.
/**
* Set up a new permission for tabs.
* Grant access under admin -> user management -> permissions
*/
function mymodule_permission() {
return array(
'view hidden tabs' => array(
'title' => t('Node tabs visibility'),
'description' => t('Grant access to node tabs.'),
),
);
}
/**
* Implementation of hook_menu_alter().
* Show/hide tabs according to permission settings.
*/
function mymodule_menu_alter(&$items) {
$items['node/%node/edit']['access callback'] = 'user_access';
$items['node/%node/edit']['access arguments'] = array('view hidden tabs');
}
Also tried using this code, which kinda works but disables edit tab on all content types and for all roles.
function mymodule_menu_alter(&$items) {
$items['node/%node/edit']['type'] = MENU_CALLBACK;
}
Obejective: Hide node "edit" tab for certain content types and roles in D7.
/edit
at the of of the address anyway, right?