0

I have read the link : hook_menu

Snippet from the page

"access callback": A function returning TRUE if the user has access rights to this menu item, and FALSE if not. It can also be a boolean constant instead of a function, and you can also use numeric values (will be cast to boolean). Defaults to user_access() unless a value is inherited from the parent menu item; only MENU_DEFAULT_LOCAL_TASK items can inherit access callbacks. To use the user_access() default callback, you must specify the permission to check as 'access arguments' (see below).
"access arguments": An array of arguments to pass to the access callback function, with path component substitution as described above. If the access callback is inherited (see above), the access arguments will be inherited with it, unless overridden in the child menu item.

But Still unclear about what access arguments are actually used for ? Are the access arguments the permissions ?

1 Answer 1

2

Access arguments is the key for an array which contains the user permission. This means that current user must have this permission to access this page.

We can use already defined user permision or can create new permission for our menu item.

If you go to permission page (Administer >> User Management >> Permissions), you can see the list of string you might use for access arguments.

If you want to create new permission for your menu item, you can implement hook_permission in your module.

4
  • is it mandatory to write the access arguments
    – harshal
    Commented Sep 12, 2013 at 4:25
  • are we using the already set permissions or are we creating new permissions here?
    – harshal
    Commented Sep 12, 2013 at 4:26
  • 1
    Yes, if you want to allow all user to access this page, you can provide "access content" permission. Commented Sep 12, 2013 at 4:26
  • @harshal, update the answers. Commented Sep 12, 2013 at 4:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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