Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

how can I check user's access first based on some permission and if user passed this check then execute access callback function with some parameters in path, some thing like this:

$items['order/add/%node'] = array(
  'title' => 'Place new order',
  'page callback' => 'drupal_get_form',
  'page arguments' => array('order_add_form', 2),
  'access callback' => 'order_add_access',
  'access arguments' => array('place order', 2),
  'type' => MENU_LOCAL_TASK,
  'file path' => drupal_get_path('module', 'order'),
  'file' => 'order.page.inc',
share|improve this question
up vote 5 down vote accepted

Not sure exactly what you mean there but your code already has a custom access callback specified as well as access arguments?

You could have an access callback like this:

 * Add order access callback
function order_add_access($op, $node){

 switch ($op) {
   case 'place order':
   // Return true, if logged in user has administer nodes permission
   // and node status is published.
   if (user_access('administer nodes') && $node->status == 1) {
     return TRUE;
 return FALSE; // default

share|improve this answer

If the first item of the access arguments is the string for the permission the user should have to access the menu item, you could use the following code.

function order_add_access($permission, $node) {
  if (user_access($permission)) {
    // Check any node property, and return TRUE when the user should access the menu item.

  return FALSE;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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