11 апр. 2012 г.

Drupal - Отключить пункт меню для роли

function hook_menu(){
    $items['mypage'] = array(
    'title' => 'My page',
    'page callback' => 'mypage_show',
    'page arguments' => array($user->uid),
    'access callback' => 'mypage_access',
    'access arguments' => array($user->uid),
    'type' => MENU_LOCAL_TASK,
  );
  return $items;
}

function mypage_access($uid) {
  global $user;
  $account = user_load($uid);

  return in_array(14, array_keys($account->roles)); //14 - id of checked group
}