I have some content type with a term reference field (think a magazine site where news are linked to a category).

I must block the node view for a user role, but I don't want to set this access for single node (like tac/tac_lite do), but for single category linked to the node (via term reference field). For example I want that role "FOO" can see node of category "BAR" but not nodes of category "XYZ", where "BAR" and "XYZ" are terms od f the same vocabulary.

My idea is this:

  • add a select list field to the vocabolary's fields (and the allowed values will be the role's ID) so that I can link role to each category/term
  • when a user try to access to a node, I check (via hook_node_access() ) that current user's role is available in the node's category fields (that I have setted in previos step).

Is there a better way ?


1 Answer 1


You can do your own implementation of hook_node_access in a custom module. It passes you the node and the user object, so you can check for certain criteria, and limit access appropriately.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.