0

I'm running a D7 site where every user profile has a 'entity reference' field referencing to their manager.

All I want to do is to create a list of the users sharing the same manager in context to logged-in user.

Can anyone please help

1 Answer 1

2

You need two entity references and a contextual filter to accomplish this.

The contextual filter does not use either of the relationships. Just select provide default value, User ID from logged in user.

The first relationship will get you the manager of the currently logged in user: User entity referenced from field_manager

The second relationship will get you the users that have that manager reference: User referencing User from field_manager. Set this relationship to use the other relationship. That's the first dropdown after you create the relationship.

Then you can simply add the User name field to your view and set it to use the second relationship (User referencing User from field_manager).

Any questions let me know. I have this running on a stripped down local install of Drupal 7.

1
  • Thanks @Jon Reid, you are a life saver. It all works but the only problem I'm having now is also renders the logged in user as well which is in this case is 'me'. How do I only get the users who shares the same manager as me but not 'me'
    – Ozyy
    Commented May 29, 2015 at 13:41

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.