I can't find the way to display a link in the management menu for specific roles. The link shows up only for administrator, despite all the access callbacks I tried.
In the view displayed by the page callback I declared same path, menu and access callbacks. As I don't know who is called last between module code and the view (?), I also tried with no menu nor access settings in the view.
If you could have a look at my implementation to check where I'm wrong ? Thanks a lot
function vts_dashboard_menu() {
$items['admin/backoffice/production'] = array(
'title' => 'Production',
'description' => 'Edit catalogue',
'page callback' => 'vts_dashboard_backoff_circuits',
'access callback' => 'vts_dashboard_user_has_role',
'access arguments' => array('éditeur voyages', 'éditeur taxonomie', 'administrator'),
'type' => MENU_NORMAL_ITEM,
'menu_name' => 'management',
//2 alternative tests below. EVEN WITH TRUE, doesn't show up for non admin
//'access callback' => TRUE,
//OR ...
//'access callback' => 'node_access',
//'access arguments' => array('view', 1),
);
$items['admin/backoffice/production/circuits'] = array(
'title' => 'Circuits',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
'access callback' => 'vts_dashboard_user_has_role',
'access arguments' => array('éditeur voyages', 'administrator'),
);
// ... more items...
);
//page callback function
function vts_dashboard_backoff_circuits(){
$viewname = 'circuits_vts';
$viewdisplay = 'backoffice_products_list';
return views_embed_view($viewname, $viewdisplay);
}
//access callback function
function vts_dashboard_user_has_role() {
global $user;
$roles = func_get_args();
foreach ($roles as $role) {
if (in_array($role, $user->roles)) {
return TRUE;
}
}
return FALSE;
}
Precision : these roles can see the pages/tabs called if they access directly to the path.