I have a link looking like this:
members/get-certificate/<user_id>/<group_id>/<pass date>
The access callback should work like this:
if($user->uid == <user_id>)
{
//any user can get his own certificate
<generate certificate>
}
else
{
//user with low admin priviledges can generate a certificate for any user
if (user_access('low admin task'))
{
<generate certificate>
}
else
{
print "Access denied";
}
}
In hook_menu
I wrote this:
$items['members/get-certificate'] = array(
'page callback' => 'members_get_certificate',
'access callback' => 'members_access_get_certificate',
'access arguments' => array('access content', $user_id),
'type' => MENU_CALLBACK,
);
Access callback
function members_access_get_certificate($permission, $user_id)
{
global $user;
if ($user_id != $user->uid)
{
if (!user_access('low admin task'))
{
return false;
}
}
return true;
}
Page callback
function members_get_certificate($user_id, $group_id, $pass_date)
{
//generate certificate
}
Problem
Unfortunately, $user_id is undefined in members_access_get_certificate
and I am unable to do the validation. How can I pass the parameter from URL into the callback?