0

I am trying to figure out how to provide access to nodes of the users, which have referenced users. Please note that users are referenced not from nodes, but the user profiles, so I can not use the Node access user reference module. I also can not use roles-based access modules, because otherwise there would be too many roles to create as users on this website should be able to reference unlimited users. I also can not user organic groups.

So basically users have other users referenced from their profiles. All referenced users should have access to nodes authored by the users who referenced them.

  • How did you implement that " users are referenced ... user profiles"? Is that an entity reference field in which the user adds a reference to each user that should have access? Also, what's the reason why you cannot use Organic Groups? – Pierre.Vriens Dec 2 '16 at 9:40
0

That will require custom code.

Here's one way to achieve it:

You'll need to use hook_node_view to get involved when the node is about to be rendered. Your code should:

  1. Check the node's author and use user_load to gain access to the referenced users
  2. Check to see if the current user (global $user) is in the list of referenced users
  3. Permit or deny the node view, or change how the node displays, depending on the result.
  • Fair enough. I thought so myself, but hoped there is already some kind of ready-to-use solution. – Nick Jun 21 '16 at 6:05
  • Not that I'm aware of, it's a pretty niche use-case I think. – Darvanen Jun 21 '16 at 6:27

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.