0

I would like to filter a search_api based view using the current user's roles as input. I don't see a contextual filter for the current user in my search_api based content view at all. How can I accomplish something like the "Published or has role" feature of this contrib module? This one seems to only work on non-search_api views.

5
  • Try adding a Relationship for User ID, then the Contextual may appear. Sorry I haven't checked this, flying blind for now. – prkos Jan 29 at 17:21
  • @prkos There is an option to add a relationship to the Author but I am not interested in the Author. I just want the current site user. – lolcode Jan 29 at 19:02
  • What is the connection between user roles and your content? – prkos Jan 29 at 19:45
  • If they are staff they can see it even if it is unpublished. If not the view should be filtered by published. I can't use the trick of putting two views on one path since this view is embedded in a block field. – lolcode Jan 29 at 20:06
  • 1
    This sounds like a node access issue. If you have node access properly sorted out so that only appropriate roles see restricted content Views will honor that. – prkos Jan 29 at 23:29
0

Thanks to @prkos reminding me that this is a regular node access setup issue. This was solved when I found this issue in the search_api queue about incompatibility with "View All Unpublshed content"

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.