Same name and namespace in other branches
- 4.7.x developer/examples/node_access_example.module \node_access_example_node_grants()
- 5.x developer/examples/node_access_example.module \node_access_example_node_grants()
Implementation of hook_node_grants().
Since we are restricting access based on a permission, we need to check that permission and return the appropriate result.
File
- developer/
examples/ node_access_example.module, line 53 - This is an example illustrating how to restrict access to nodes based on some criterion associated with the user.
Code
function node_access_example_node_grants($account, $op) {
$grants = array();
if (user_access('access content', $account)) {
$grants[] = 0;
}
if (user_access('access private content', $account)) {
$grants[] = 1;
}
return array(
'example' => $grants,
);
}