I have set up a site with role access permissions for different node types. For just one node, I have to remove de access permissions for just one single role, the others will stay unchanged. Because the site has already installed many modules I prefer to use only a hook function instead of a module as nodeaccess or content access. Can somebody please advise for the hook script?
Asked
Active
Viewed 267 times
1 Answers
1
This should work, adjust operation, user role and node type as needed:
function mymodule_node_access($node, $op, $account) {
if (in_array('the role', $account->roles) && $op == 'view' && $node->type == 'article' && $node->nid == 42) {
return NODE_ACCESS_DENY;
}
}
You could leave out $op and $node->type in the conditional statement if this is just for a single nid.

Dooderoo
- 229
- 1
- 2
- 13
-
Dear Doodero thank you very much for your answer. I would like to use this for authenticated users, other user roles are allowed to have acces. I tried authenticated as role but this seems not to work. Is authenticated not a real role?? – Christiane Peschen Mar 02 '14 at 01:25