2

This is the menu I have.

  $items['start'] = array(
    'title' => 'Take A Test',
    'page callback' => 'qe_start',
    'access callback' => TRUE,
    'expanded' => TRUE,
  );  

return $items;

What should be passed in this to make it accessible to a role/logged in user?

'access arguments'    => array('content'),

And how can I make this to a callback_menu?

3

If you actually just want to check if the user is logged in and don't want to set up permissions, you can set the access callback to 'user_is_logged_in':

$items['start'] = array(
  'title' => 'Take A Test',
  'page callback' => 'qe_start',
  'access callback' => 'user_is_logged_in',
  'expanded' => TRUE,
);  
1

You would normally define a permission for your module/page using hook_permission() and then assign that permission to a particular role/set of roles in the admin section.

You can then use that permission in your menu callback safe in the knowledge that only the roles you've allowed can access the page:

function qe_permission() {
  return array(
    'take a test' => array(
      'title' => t('Take a test')
    ),
  );
}

function qe_menu() {
  $items['start'] = array(        
    'title' => 'Take A Test',
    'page callback' => 'qe_start',
    'access arguments' => array('take a test'),
    'type' => MENU_CALLBACK,
    'expanded' => TRUE,
  );

  return $items;
}

The permissions admin page is at http://mysite.com/admin/people/permissions just in case you haven't already seen it.

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.