hook_node_grants
hooks/core.php, line 1178
- Versions
- hooks
hook_node_grants($account, $op)
Inform the node access system what permissions the user has.
This hook is for implementation by node access modules. In addition to managing access rights for nodes, the node access module must tell the node access system what 'grant IDs' the current user has. In many cases, the grant IDs will simply be role IDs, but grant IDs can be arbitrary based upon the module.
For example, modules can maintain their own lists of users, where each list has an ID. In that case, the module could return a list of all IDs of all lists that the current user is a member of.
A node access module may implement as many realms as necessary to properly define the access privileges for the nodes.
For a detailed example, see node_access_example.module.
Parameters
$account The user object whose grants are requested.
$op The node operation to be performed, such as "view", "update", or "delete".
Valor de retorno
An array whose keys are "realms" of grants such as "user" or "role", and whose values are linear lists of grant IDs.
Código
<?php
function hook_node_grants($account, $op) {
if (user_access('access private content', $account)) {
$grants['example'] = array(1);
}
$grants['example_owner'] = array($user->uid);
return $grants;
}
?> 
Comentarios recientes
hace 17 horas 50 mins
hace 1 día 10 horas
hace 1 semana 21 horas
hace 14 semanas 4 días
hace 19 semanas 19 horas
hace 20 semanas 2 días
hace 20 semanas 5 días
hace 20 semanas 5 días
hace 21 semanas 2 días
hace 22 semanas 1 día