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

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.

  • 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 May 29 '15 at 13:41
  • @Ozyy if this worked for you, please accept the answer by clicking the green check mark. – No Sssweat May 29 '15 at 16:30
  • Hey @Ozyy sorry I missed your additional question until now. Glad you got it all sorted! – Jon Reid Jun 1 '15 at 16:20

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.