Skip Navigation

[Resolved] Access – restricting posts by taxonomy term

This support ticket is created 5 years, 5 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.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 1 reply, has 2 voices.

Last updated by Beda 5 years, 5 months ago.

Assisted by: Beda.

Author
Posts
#1268735

We would like to restrict access to posts (inbuild & custom posts) based on the taxonomy term selected.

Eg only user role 'directors' can view posts that have taxonomy term 'financials' selected.

#1269069

Toolset Access Taxonomy controls do not allow control over who can see what related to the Posts tagged with Terms from those Taxonomies, instead, it allows to control who can Manage terms (access the taxonomy terms list), Edit terms (edit any term), Delete terms (delete terms) and Assign terms (assign terms to their respective post types).
https://toolset.com/documentation/user-guides/setting-access-control/#taxonomy

Hence, to hide Posts from either an Archive List or a View Loop or in single templates, you'll have to fall back to the following resources, which are Access ShortCodes and HTML Conditions.

1. HTML Conditions will help you determine what precise tag is assigned to the current post, whether in a Loop of any kind or on a single Post template. The general syntax to check whether a post has or has not a given term assigned is:

[wpv-conditional if="( CONTAINS(#(taxonomy-slug),'term-slug') )"]
<p>This consultant speaks Chinese!</p>
[/wpv-conditional]

https://toolset.com/documentation/user-guides/conditional-html-output-in-views/, https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/

2. Toolset Access ShortCodes allow to hide or show content based on User Roles (HTML Conditions can do that too, BTW). THe general syntax is:

[toolset_access role="Author" operator="deny"]cannot see[/toolset_access]

https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/

Now, to dynamically control this without the need to edit every single post, you could:
- apply a Content Template to the single posts so you need to set the Rules only once in the Content Template
- Use Views or Archive Loops to display many posts and control the output with the above-explained tools inside the Loop, so it applies to each post in the loop.