Hiding menu items dynamically I am developing an application based on Drupal 7 and web services. Some application pages have a menu which should be customized (menu items should be removed) based on the response from the web service, but am not sure on how should implement it.

In general the logic is the following: I will get a parameter from the request and call the web service with PHP (I know how to do this). Then, based on the response, I should show or hide some menu items.

The problem is that the menu should be customized in every request, so hook_menu_alter does not help me, because it is only called once when the menu is created. Is there another hook that I should be looking into, or any other method I should be using?
use theme_menu_link() to modify your menu links on the fly:


style="display:none"
class="invisible"


e.g.

function mytheme_menu_link(array $variables)
{
   if ($variables['element']['#href']=='temp-menu-link') {
       $variables['element']['#attributes']['class'][] = 'invisible';
   }
   return theme_menu_link($variables);
}


Security note: It'll still be possible to access the URL, thus a "state check" must be implemented on the receiving end if temporarily invisible also means 'not permitted to call'.