In my module:
function mymodule_menu() {
$items['reports'] = array(
'page callback' => 'reports',
'type' => MENU_CALLBACK,
'access arguments' => array('access content', 'hr functionality')
);
return $items;
}
function mymodule_permission() {
return array(
'hr functionality' => array(
'title' => t('HR functionality'),
'description' => t('Do things only HR are allowed to do.'),
)
);
}
I set HR to have "HR functionality" permissions. I logged in as a user with HR role, and I get access denied to my reports page. I tried clearing cache, etc. If I remove the "hr functionality" access argument it lets me in.
Even if I log in as admin, I get access denied.
What am I doing wrong here?
EDIT: The method I ended up writing per accepted answer:
function multiple_permission_callback() {
global $user;
$permissions = func_get_args();
if (empty($permissions))
return false;
foreach ($permissions as $permission) {
if (!user_access($permission, $user)) {
return false;
}
}
return true;
}
TRUE
. That might not be the best security practice. It's an easy fix though,if (empty($permissions)) { return FALSE; }
before the loop