我在模块中使用了"hook_node_grants()“,但它从不运行(invoke)。
注意,"hook_node_access_records“是正确的。
function mymodule_node_grants($account, $op) {
dpm($op);
$grants = array();
if ($op == 'view' || $op == 'update') {
$grants['guser'] = array($account->uid);
}
return $grants;
}
function mymodule_node_access_records($node) {
if (!empty($node->guser)) {
$grants = array();
$grants[] = array(
'realm' => 'guser',
'gid' => user_load_by_name(array('name' => $node->guser))->uid,
'grant_view' => 1,
'grant_update' => 1,
'grant_delete' => 1,
'priority' => 1,
);
return $grants;
}
}
发布于 2015-04-18 23:43:15
也许this answer帖子会对你有所帮助。
总而言之,如果您正在测试以管理员身份登录的代码(UserID: 1),将不会调用hook_node_grants。
此外,如果您所使用的用户的角色启用了绕过节点访问权限,那么将不会调用某些source code。
https://stackoverflow.com/questions/29714716
复制相似问题