I am trying to do something like this:
https://toolset.com/forums/topic/limit-search-to-custom-post-type-posts-created-by-logged-in-user/
However, I would like to allow certain user roles to view all posts, such as admins, but perhaps another intermediate user role as well.
Thanks for contacting us!
What you want to achieve is possible with conditional statements in the views loop.
Here you check if Current user === post author:
[wpv-conditional if="('[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='ID']')"]
your content to display if condition is true
[/wpv-conditional]
To check for user role you need:
[wpv-conditional if="( '[wpv-current-user info='role']' eq 'your_role' )"]
your stuff here
[/wpv-conditional]
To do this use the "conditional" button together with Fields and Views button.
You have to add one conditional statement for each role and edit "eq" or "ne" (not equal) if you want to hide/show your content.
Further documentation is here:
=> https://toolset.com/documentation/views-shortcodes/#wpv-current-user
=> https://toolset.com/documentation/views-shortcodes/#wpv-post-author
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
If I misunderstood, please provide more detail what you want to achieve exactly.
For further information or if you have any questions related to this ticket
please do not hesitate to contact us.
Thanks. I think that's exactly what I was looking for.
Here is how I set it up so administrators and the author could both view content:
[wpv-conditional if="('[wpv-current-user info='id']' eq '[wpv-post-author format='meta' meta='ID']') OR ('[wpv-current-user info='role']' eq 'administrator')"]