0

As I understand for a menu access argument I must specify a permission.

So, let say there is a permission for "Profile: Create new content" that is enabled for authenticated users, and I would like to use this as my menu access check.

This is how I put it in my menu callback?

function mymodule_menu() {
  $items = array();

  $items['play'] = array(
    'title' => 'Play',
    'page callback' => 'play',
    'access arguments' => array('Profile: Create new content'),
    'type' => MENU_CALLBACK
  );

  return $items;
}

This does not work though, so how do I get the permission name used by the system?

1

This is based on Drupal 6 but I doubt it has changed.

access arguments returns true if the user has the permission specified in the array, however, it does not make sure to create that permission if it doesn't exist. If you want to use a module specific permission you need to define it using hook_permission (hook_perm for D6). If there already exists a permission that will suit you needs you can simply call that instead, though.

| improve this answer | |
  • Thanks, would you know how I find out the internal permission name? "Profile: Create new content" seems to be just a title presented to users, but I guess, this would be "create profile"? – giorgio79 Sep 27 '11 at 14:19
  • The second answer in this question mentions you can extract the internal name from the checkbox value but I can't test that. I am not entirely sure how hiding the name is an improvement. – Quail Sep 27 '11 at 14:34

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.