I have 2 user roles: Moderator and Company. Each Moderator has a set of companies; for example:

  • Moderator A owns Company d, e, anf f

  • Moderator B own Company g, h, and i

When moderator A logs in, I want that moderator can only see Company d, e, and f. I want to use a view.

How can I achieve this? How can I restrict each moderator to see those companies (which, I repeat, are user accounts) they own?

2 Answers 2


Have a look at the Group module which is like a "little brother" of Organic groups. It only started in D7 and with a D8 version in the pipeline. Personally I'm more and more considering/using it as a potential alternative for the Content Access module. And since it is all Entity based, there are lots of ways it can be used in combination with the Rules module also.

Specific to your question here, I think what is going to help you a lot is the Group member profiles submodule, which you can use to create multiple fieldable member profiles and which can be attached to a member.

For way more details about this module, refer to:

Also, as per your comment below (= "Can you tell me if it works with views? I would like to display in a view all the companies attached to the user (Moderator) that is logged in."): I suggest you have a look at comment nr 2 in the issue about "How to list groups in a view?", which even includes a view in export format you may want to have a look at.

Note: Your question doesn't specify which version you are using, but this answer applies for both D7 and D8.

  • Thank you for the response! I'll take a look at this promising module. Before I try it, can you tell me if it works with views? I would like to display in a view all the companies attached to the user (Moderator) that is logged in.
    – Drii7
    Apr 3, 2016 at 12:51
  • Hi again. I'm having trouble to understand the views... I created a group type and a role "Moderator" inside. I added 3 users to the group, and one user has the role "Moderator". In the view, I want to display only the members of the group taht belong to the logged in user. I tried to use relationships with views but I'm missing something. Here's how my view looks like: imgur.com/jBUzG3Y
    – Drii7
    Apr 3, 2016 at 15:49
  • The views part was solved here: drupal.org/node/2699371#comment-11034833
    – Drii7
    Apr 3, 2016 at 23:14

If moderators are creating the Company nodes themselves, you will probably be best off with the Content Access module.

If Company nodes are created by administrators, you could use the Node access user reference field to reference the moderators. They would then get the necessary view permissions.

Let me know if I missed your question.

  • Thank you for your response. The thing is, Company is not a content type that creates nodes. It's a role that creates users. I installed entity reference and I told the "company d", that its moderator is "Moderator A". Now I need to tell the user "company d" that it can only be seen by Moderator A. Can I do this with nodeaccess_user reference? I hope I'm explaining this well
    – Drii7
    Apr 2, 2016 at 22:09
  • I think I get it now; so you want to grant Moderator users to see only Company users they have created? Apr 3, 2016 at 8:01
  • yes! But the users are created by admin
    – Drii7
    Apr 3, 2016 at 12:32

Your Answer

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

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