Enable/disable a menu item programatically depending on a variable value I need to show a menu item only in certain moments. Imagine that I've a form with some options. If 'A' is selected, I need to enable a menu item that has a form for adding information about 'A'. 

I have done a module that has a hook_menu like this:

&gt; function secciones_menu() {
&gt;   
&gt; 
&gt;   $items = array();
&gt; 
&gt;       $items['secciones'] = array(
&gt;           'title' =&gt; t('Crear Sección'),
&gt;           'description' =&gt; t('Crear Secciones'),
&gt;           'page callback' =&gt; 'drupal_get_form',
&gt;           'page arguments' =&gt; array('secciones_wizard'),
&gt;           'access callback' = TRUE,
&gt;           'type' =&gt; MENU_NORMAL_ITEM,
&gt;           'menu_name' =&gt; 'main-menu',         'customized' =&gt; 1, // Must be 1 in order to not dispaly the link in any language
&gt;           'language'  =&gt; 'es', // language is required in order to make the item translatable   );  

return $items; }


And then have my form for 'A'. So how I can enable or disable the menu item, depending a variable value?

Thank you !

EDIT 1:

What I've done is change the access callback and the menu type:

function agenda_menu() {


  $items = array();


  $items['agenda'] = array(
        'title' =&gt; t('4. Crear agenda'),
        'description' =&gt; t('Crear agenda'),
        'parent'=&gt;array('Configurar Revista'),
        'page callback' =&gt; 'drupal_get_form',
        'page arguments' =&gt; array('agenda_wizard'),
        'access callback' =&gt; 'agenda_access_callback',
        'type' =&gt; MENU_DEFAULT_LOCAL_TASK,
        'menu_name' =&gt; 'main-menu',
        'customized' =&gt; 1, // Must be 1 in order to not dispaly the link in any language
            'language'  =&gt; 'es', // language is required in order to make the item translatable
  );


  return $items;
}


And then I've done the next code:

function agenda_access_callback(){

    //db query
    //insert that query in $options array
    foreach ($result as $row) {
        $options[$row-&gt;id_seccion] = $row-&gt;id_seccion;
    }

    if(isset($options)){ //if the array is not empty
        return TRUE; //the menu item is visible
    }
    else{
        return FALSE; //otherwise, is not visible
    }
}


Ok, this is what I have done, but it doesn't work. Any idea? Thank you.
The usual way to enable a menu item only in certain circumstances is to use a custom access callback, in which you would evaluate whether this option is set. So:

'access callback' = 'my_module_access_callback',
...

function my_module_access_callback() {
   return my_module_test_option_is_true();
}


But it's a little hard to be sure if this will work for your case as you haven't given us much to go on.