I'm currently developing on Drupal 6-rc1. Clean URLs are enabled. I have very little code, and I've read the handbook guides I have no idea whats wrong with this code, this is literally all I have written so far. Not that it matters but the site is set up as a subdomain.mydomain.mysite (this works fine I can easily get there with the url subdomain.mydomain/mysite). I have no idea what is wrong with this code, from everything I've read it should work fine its really annoying though. I receive an access denied error every time I try to with the URL subdomain.mydomain/mysite/accountant (so Drupal knows it exists it just thinks I don't have access). I've only been testing under the "super user" account so I believe it shouldn't be giving me an access denied at all. I've looked at the other modules included with Drupal 6-rc1 and they have pretty much the same code as me. Maybe I just need some fresh eyes.

function accountant_perm() {
  return array('access accountant');
}

function accountant_menu() {
  $items['accountant'] = array(
    'type'             => MENU_CALLBACK,
    'title'            => 'Accountant',
    'page callback'    => 'accountant_main_page',
    'access callback'  => 'user_access',
    'access arguments' => array('access accountant'),
  );
  return $items;
}

function accountant_main_page() {
  return t('Text');
}

Comments

jcarreer’s picture

The problem was something to do with how Drupal caches information about my module. I'm not sure if this is how most people do things but when I'm working on a module I enable it almost immediately and do some basic unit tests on every non standard function I write. Apparently there was some left over information about my modules menu and/or its permissions (at one point I had no permissions which will give a access denied message for the Super Administrator). However I found that disabling then re-enabling my module fixed the problem. Sorry to waste forum space, this post should probably be deleted.

acomer’s picture

I think that you can just visit the administrate menu page to refresh the menu cache, without having to disable/re-enable your module.

Alex Comer
Platinum Code
www.platinumcode.com

pwolanin’s picture

go to admin/build/modules to force a menu rebuild. Or, you can use the devel module which has a link in the block to do the rebuild from any page.

---
Work: BioRAFT