Home › Toolset Professional Support › [Resolved] Only allow users to view / edit their own posts, except for certain user roles
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Tagged: Access plugin, Layouts plugin, Toolset Forms, Views plugin
This topic contains 3 replies, has 3 voices.
Last updated by richardG-4 6 years, 9 months ago.
Assigned support staff: Tom.
I am trying to do something like this:
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
To check for user role you need:
[wpv-conditional if="( '[wpv-current-user info='role']' eq 'your_role' )"]
your stuff here
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:
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')"]
Known issues and solutions
Frequently asked support questions
Support tickets archive
Get help from experienced contractors
Meet Toolset support team
Toolset Customer Support Policy
Need to tell us something about the quality of support
How to remove personal information from your database for support