Skip Navigation

[Resolved] Displaying different Posts and Custom Fields based on User Role

This support ticket is created 5 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

This topic contains 1 reply, has 2 voices.

Last updated by Beda 5 years, 9 months ago.

Author
Posts
#952394

I have a custom post type that I have created with the Types plugin. Within this post type are about 25 fields that I created via Toolset.

I have three user roles, "Customer," "Manager," and "Owner".

One of my fields is "Show to Customer", a simple true/false field.

Here's what I need to accomplish:

I need a single page that displays a view that's dependent on your user role.

The "Customer" role can only see the posts where "Show to Customer" is true. "Customer" role sees only 5 of the 25 fields.

The "Manager" role sees all the posts but only 15 of the 25 fields.

The "Owner" role sees everything -- all posts, all 25 fields.

Can I use the Views plugin in combination with the Access plugin like this?

#952767

I suggest to do it like this:

1. Create a View and query the post type
2. Create a View and add a Conditional HTML to check upon your "Show to Customer" field, and the current user role.
https://toolset.com/documentation/user-guides/conditional-html-output-in-views
3. Insert this View to any page to see the output as the determined roles.

Or:
1. Create 2 Views and return each exactly the posts you want (add Query Filters that check upon the "Show to Customer" field)
2. Insert the Views to a page and wrap them in Toolset Access ShortCodes that check upon the user role:
https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/
3. Visit the page and see the output as the determined roles.

Let me know if you have further questions.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.