Hello. Looking for advice on the best way to go about and how to filter search results based on user role.
My setup: private site with 3 distinct user roles that represent investor groupings. I use the Members plugin to add and assign the roles to users. A user may have more than 1 role. Content (grouped by post category) is restricted and only viewable for roles that have access to it. So, if User 1 is assigned Role A, they will only be able to see/access content that is in a post Category A. If user 2 is assigned Role A and Role B, they will be able to see/access content that is in post categories called “A” and “B”. etc. I use the Content Control plugin to manage the access restrictions.
All good so far. Now I want to be able to have a search box that will allow a user to search a term, but have the results filtered so that only content in categories they have access to will be displayed. Right now results from all categories are displayed (and those that they don’t have access to show the title and meta data with “This content is restricted.” as the excerpt). What I want to achieve is to totally filter out these results so they don’t even show up on the search results page.
I’d prefer to work directly with code in my child theme functions.php file, but will to look at a plugin that I could reverse engineer.
Any thoughts?