2

I have a private group with a "notebook"...most pages of that notebook may be accessed by all members of that group, but some pages shouldn't. I tried to control access with the module "Content access" but that only works with node types that are not part of any group because organic groups seems to grant access to all nodes if the user belongs to that group. Is there a way to deny access (based on roles) to nodes that belong to a group if the user is in the group?

2

Install the Module Grants module. It will solve the conflict. Actually, it will take the conflict into account, which Drupal does not.

Module Grants makes modules that deal with content access permissions operate better on unpublished (as well as published) content. It also makes sure that access grants behave in an orderly fashion when such modules are used together.

1

You can use the hook_node_access function for this. You can build an array of all your nodes and check this every time a user (linked with his role) access a node. You can allow, deny or ignore the request.
If you can't figure it out yourself, provide me with some info and I'll make you an example.

  • That hook is D7 only and the D6 equivalent "hook_access" doesn't seem to get called - not even from the atrium_book feature module... – Philipp Horn Jan 23 '12 at 14:47
  • I'm sorry, I didn't saw the 6-tag! Why do you thing the hook_access isn't being called? – Michiel Jan 23 '12 at 15:00
  • I added the hook to the atrium_book feature (atrium_book.module) with a simple dpm("foo") and nothing happens when I view a book node (I cleared the cache and I tried it with a non-user1 account) – Philipp Horn Jan 23 '12 at 15:08
  • 2
    @PhilippHorn it is not a good idea to edit core or contributed modules. It would be better to create a new module in which to call your own hooks and extend the functionality of other modules. That way you can still easily upgrade contributed modules. – drmonkeyninja Jan 23 '12 at 15:14
  • Here is some valuable advice! +1 – Michiel Jan 23 '12 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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