I want to fetch all menu item list from specified menu list, I can fetch all of them with menu_tree_all_data, It return all item of menu and when I looked in in result I don't see enabled property my sample code


(after that I put this in foreach statement and print them, but I want exclude disabled menu items)

My question is how can I find out that the menu item is disabled ?


'hidden' key in the array returned, will tell you if the menu links is enabled or disabled. For all disabled menu links hidden will be '1'.


I am trying to remove some menu items from the admin menu (which don't have any value in "title" field. We can have any other criteria to identify our target menus) as below (in theme_preprocess_page()).

Please note:

  1. We are not supposed to make any changes in the already defined access configurations for those menus. We are not supposed to make any changes in the menu path.

  2. Here, in this use case, the menus were showing in admin-menu list as those started with "admin/". Example: "admin/entity_ref_search/%".

  3. We need to clear cache after adding this code (as changes are related with menu).

$menu_tree = menu_tree_all_data('management');
foreach ($menu_tree as $key => $menuItem) { // Runs once
  if (isset($menuItem['below']) && is_array($menuItem['below']) && !empty($menuItem['below'])) {
    foreach ($menuItem['below'] as $menu_link => $value) {
      if ($value['link']['title'] == '') {
          $value['link']['hidden'] = 1;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.