I'm trying to implement an access callback per role for a specific menu item, but other roles can view that menu item also. Any tip is welcome.
/**
* Implements hook_menu();
*/
function MODULENAME_menu() {
global $user;
$items['admin/backoffice/production/taxonomie'] = array(
'title' => 'Taxonomie',
'type' => MENU_LOCAL_TASK,
'weight' => 0,
'page callback' => 'MODULENAME_backoff_taxonomy',
'access callback' => 'MODULENAME_user_has_role',
'access arguments' => array($user, array('éditeur taxonomie', 'administrator')),
);
return $items;
}
function MODULENAME_backoff_taxonomy(){
module_load_include('inc', 'taxonomy', 'taxonomy.admin');
$form = drupal_get_form('taxonomy_overview_vocabularies');
drupal_set_title('Backoffice - Taxonomie');
return drupal_render($form);
}
function MODULENAME_user_has_role($user,$roles) {
foreach ($roles as $role) {
if (in_array($role, $user->roles)) {
return TRUE;
}
}
return FALSE;
}