I'm trying to learn Drupal 6 access control with these instructions: http://drupal.org/node/109157
I'm trying to figure out the function of 'access arguments' inside the menu_hook.

For example, here is a clip of webform module's menu hook:

['node/%webform_menu/submission/%webform_menu_submission/edit'] = array(
'title' => 'Edit',
'load arguments' => array(1),
'page callback' => 'webform_client_form_load',
'page arguments' => array(1, 3, TRUE, FALSE),
'access callback' => 'webform_submission_access',
'access arguments' => array(1, 3, 'edit'),
'weight' => 1,
'type' => MENU_LOCAL_TASK,

It's unclear to me what these numbers mean in 'access arguments'? Could someone explain me a bit of 'access arguments'? What do the numbers 1 and 3 mean??


karschsp’s picture

Where in the webform module do you see that snippet? I can't seem to find it. I'm fairly new to module development but I've only ever used something like:

'access arguments' => array('create new webform', 'access webform'),

where those access permissions are actually defined in the module's implementation of hook_perm like:

function webform_perm() {
     return array('create new webform', 'access webform', 'delete webform', 'rename webform', 'anything you like', 'etc');

looking in webform.module, here's the implementation of hook_perm()

* Implementation of hook_perm().
function webform_perm() {
  return array("create webforms", "edit own webforms", "edit webforms", "access webform results", "clear webform results", "access own webform submissions", "edit own webform submissions", "edit webform submissions", "use PHP for additional processing");

you can also check api.drupal.org for more info: http://api.drupal.org/api/function/hook_perm/6

hope that helps!

wpanssi’s picture

The php I gave can be found in the webform_menu function. There are quite a lot of items. I just presented one of them.

I'm trying to implement 'access own webform results' and that's why I'm asking. I already created this new permission by modifying webform_perm(). But I need to find out what those numbers 1 and 3 mean in the 'access arguments'. I have not found any examples where 'access arguments' contains plain numbers, so If someone could help me out here I would be grateful..


ollynevard’s picture

Looking at hook_menu in the API (http://api.drupal.org/api/function/hook_menu) it describes access arguments as follows:

"access arguments": An array of arguments to pass to the access callback function. Integer values pass the corresponding URL component.

So in your example the url node/%webform_menu/submission/%webform_menu_submission/edit breaks down as:

0 =>node
1 => %webform_menu
2 => submission
3 => %webform_menu_submission
4 => edit

This means the access arguments will be:

'access arguments' => array('%webform_menu', '%webform_menu_submission', 'edit'),

The '%' in the URL of your example are parameters, probably used to insert the name of a webform, e.g.

'access arguments' => array('contact_webform_menu', 'contact_webform_menu_submission', 'edit'),

Hope this helps.