By bigheadfish on
I wrote a new module.
function ownershipclaim_menu() {
$items['node/%node/claim'] = array(
'title' => 'Claim Page Ownership',
'page callback' => 'ownershipclaim_claim',
'access callback' => 'user_access',
'type' => MENU_LOCAL_TASK,
'weight' => 90,
);
return $items;
}
function ownershipclaim_perm() {
return array('claim ownership');
}
... ...
I want all authenticated users to be able to claim node (page) ownership. In user permission table, I set authenticated user can 'claim ownership'. But when I log in as a non-privileged authenticated user, I get "Access Denied" error. (I can only claim if I log in as uid =1; even after setting authenticated users can 'edit any page content', I still get access denied error if logging as an ordinary user)
Any idea on why it occurs?
Thank you,
Comments
if you want every
if you want every authenticated user to access a path, you can accomplish it this way:
Thank you, dougstum
Hi dougstum,
Thanks. It really helps! I tried and it works well.
But I still wonder why my code does not work. I still, sooner or later, need to allow some types of users, not all authenticated users to make such claim.
Thanks again.
I think that your problem was
I think that your problem was that you didn't specify hook_menu correctly, in that you did not specify the access arguments. The menu system assumes that access callback is user_access, but you want to specify the arguments to user_access in the hook.
For example:
so here I've effectively told the menu system to test this function every time the page is loaded:
to determine whether a particular user can view the page associated with that hook_menu item.
You also have to set the appropriate permissions in your user permissions page in order for this to work, in particular you have to check the 'claim ownership' box for authenticated users.
Try that.
Rock!
Hi dougstum,
You rock!
Thanks a lot for your help.
It is an area that I obviously do not pay attention to. Many thanks to you!