1

I have three content types.

  • Article
  • Basic Page
  • Custom Page

All the content types have a field_interests field, which can have multiple values, and which is an entity reference field to the interests vocabulary.

The taxonomy terms for that vocabulary are:

  • sports
  • songs
  • movies

I have three user roles.

  • Athlete
  • Singer
  • Actor

I want to create a view in which:

  • Athlete users can view nodes for which the value of field_interests is sports
  • The Singer users can view nodes for which the value of field_interests is songs
  • The Actor users can view nodes for which the value of field_interests is movies

I am assuming filter condition should be like this

( current user's role == athlete AND "field_interests"==sports ) OR
( current user's role == Singer AND "field_interests"==songs) OR
( current user's role == Actor AND "field_interests"==movies)
// if any user has multiple user roles 
( All current user roles in [Singer , Actor] AND All "field_interests" in [songs , movies] )

I saw similar questions and I don't know how to use those answers to my exact purpose.

5
  • 1
    Roles in Drupal are not exclusive (each user can have multiple roles). So what should happen if a user has the roles of Actor and Singer? Oct 21 '21 at 11:03
  • This will be much easier if you create 3 separate views, each view showing only one "interest". And then limit access to those views by assigning the corresponding permissions to your user roles.
    – Hudri
    Oct 21 '21 at 11:10
  • @Hudri Yeah, I tried that but, If I have to create 15 views which should display content based on role and suppose I have 10 roles , In that case I have to create 150 views . Which is , I feel not a good practice. Oct 21 '21 at 11:54
  • @PatrickKenny In my case I'll make sure every user has a single role. but, In any case if user has roles of Actor and Singer, I want to add new condition like all current user roles in [Actor , Singer] Oct 21 '21 at 11:59
  • @PatrickKenny how can I set taxonomy term value dynamically seeHere, need help Nov 25 '21 at 14:04

Your Answer

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

Browse other questions tagged or ask your own question.