0

I have two hook menu items:

function myid_print_menu()
{  
    $items = array();  
    $items['user/%user/myid_print_settings'] = array(
        'title' => 'ID Print Settings',
        'description' => 'Configuration options for the myid_print module',
        'page callback' => 'myid_print_admin_settings',
        'page arguments' => array(1), 
        'access callback ' => 'myid_print_user_access',
        'type' => MENU_LOCAL_TASK, 
        'weight' => -9,   
    );

    $items['user/%user/myid_print'] = array(
        'title' => 'Print an ID',
        'page callback' => 'myid_print_user_page',
        'page arguments' => array(1),    
        'access callback' => 'myid_print_user_access',    
        'file' => 'myid_print.pages.inc',    
        'type' => MENU_LOCAL_TASK,
        'weight' => -10,
    );
    return $items;
}

function myid_print_admin_settings()
{
     return drupal_get_form('myid_print_settings_form');
}

function myid_print_settings_form()
{
     $form = array();   
     $form['summary'] = array(
         '#type' => 'fieldset',
         '#title' => t('ID Summary'),     
         '#description' => t('Summary of ID printed, submitted and reset on a specific range of time')
     );
     return $form;
}

The 'ID Print Settings' was not showing, but Print an ID was showing. I tried clearing my cache, it was still not visible. Why?

enter image description here

2
  • Make sure that Drupal is able to flush the cache without any problem by checking if there is any errors at admin/reports/dblog – gerzenstl Sep 24 '15 at 3:05
  • include the code for myid_print_admin_settings($arg)? – Darvanen Sep 24 '15 at 3:13
3

I have a feeling with the access callback. Either your function is wrong (which you haven't posted) or something is up with your permission setting for this module.

Try temporarily updating your access callback to true to verify that it is causing the issue:

'access callback' => TRUE,

and clear your cache.

I think you may be better off creating a permission using hook_permission and using access arguments instead of access callback.

/**
 * Implement hook_permission()
 */
function myid_print_permission(){
  return array(
    'administer myid_print' => array(
      'title' => 'Administer myid_print'
    ),
  );
}

/**
 * Implements hook_menu().
 */
function myid_print_menu() {  
  $items = array();  
  $items['user/%user/myid_print_settings'] = array(
      'title' => 'ID Print Settings',
      'description' => 'Configuration options for the myid_print module',
      'page callback' => 'myid_print_admin_settings',
      'page arguments' => array(1), 
      'access arguments' => array('administer myid_print'),
      'type' => MENU_LOCAL_TASK, 
      'weight' => -9,   
  );

  $items['user/%user/myid_print'] = array(
      'title' => 'Print an ID',
      'page callback' => 'myid_print_user_page',
      'page arguments' => array(1),    
      'access arguments' => array('administer myid_print'), 
      'file' => 'myid_print.pages.inc',    
      'type' => MENU_LOCAL_TASK,
      'weight' => -10,
  );
  return $items;
}
0

Try putting the call to drupal_get_form directly in your menu hook like this:

$items['user/%user/myid_print_settings'] = array(
    'title' => 'ID Print Settings',
    'description' => 'Configuration options for the myid_print module',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('myid_print_settings_form', args[1]), 
    'access callback ' => 'myid_print_user_access',
    'type' => MENU_LOCAL_TASK, 
    'weight' => -9,   
);

Note the args[1] in the arguments which will pass the %user argument from the path to the form.

0

Your Answer

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