0

I'm developing a custom module and the last step is to add custom permissions. I've added the administrator role to the new permission, but I see "Access Denied" when viewing /ledger/reports/balance-sheet. I've cleared caches, reloaded the module, and rebuilt permissions. I've even dug into the users.module file in core to verify that it is entering the if uid==1 return TRUE; section of function user_access(). Any help would be appreciated.

/***************************************************************
 * Drupal core hooks
 * *************************************************************/

/**
 * Implements hook_menu().
 */
function ledger_reports_menu() {
  $items = array();

$items['ledger/reports'] = array(
  'title' => 'Ledger Reports',
  'description' => 'List of available reports',
  'page callback' => 'ledger_reports_page', 
  'access callback' => TRUE,
  'weight' => 10,
);

$items['ledger/reports/balance-sheet'] = array(
'title' => 'Test Balance Sheet',
'description' => 'The current balance of all asset, equity, and liability accounts',
'page callback' => 'ledger_reports_balance_sheet', 
'page arguments' => array(3),
'access callback' => array('view ledger reports'),
'weight' => 10,
);


/**
 * Implements hook_permission().
 */
function ledger_reports_permission(){
  return array(
    'view ledger reports' => array(
      'title' => t('View Ledger Reports'),
      'description' => t('View the accounting reports.'),
    ),
  );
}
2

This:

'access callback' => array('view ledger reports'),

Needs to be:

'access arguments' => array('view ledger reports'),

Currently you're trying to make Drupal invoke a function by string while giving it an array - it's not going to like that very much ;)

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.