Reputation: 2239
I have a node form that the author should be able to edit, unless certain conditions are true. I would like to remove the "Edit" tab under those conditions, for the author. Power users should still be able to use the "Edit" tab.
The hook_menu_alter()
function doesn't work for me because it only gets called when the menu gets built, before it is put into cache.
I would prefer to (a) do this without adding another contrib module and (b) at the module level, instead of the theme level (for security), but am interested in hearing other ways as well.
Upvotes: 0
Views: 1846
Reputation: 36955
You can probably use Rules to do this but personally I'd use hook_node_access()
in a custom module:
function MYMODULE_node_access($node, $op, $account) {
if ($op == 'edit') {
if ($some_condition) {
return NODE_ACCESS_ALLOW;
}
return NODE_ACCESS_DENY;
}
return NODE_ACCESS_IGNORE;
}
Upvotes: 5