Skip Navigation

[Resolved] Restricting certain user to only post under specific taxonomies

This thread is resolved. Here is a description of the problem and solution.

Problem:

I want to be able to restrict certain user to only post under specific custom taxonomies.

Solution:

I assume you are using shortcode [cred_field] to render the "Location" taxonomy field.

There isn't such a built-in feature within Toolset form plugin, see our document:

https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field

You might consider custom codes, you can check it with our experienced contractors.

Relevant Documentation:

This support ticket is created 6 years, 2 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by haryonoS 6 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#1106825

I want to be able to restrict certain user to only post under specific custom taxonomies.

Let's say I have a custom post "Movie Review" with custom taxonomy "Movie Genre" that holds "Action", "Comedy", "Horror", etc.

I want user A to only post under "Action" while allowing user B to post under both "Comedy" and "Horror".

How can I achieve this?

#1106829

Forgot to add that I would like to implement this on frontend CRED form

#1106885

I thought it might be more helpful if I explain the real situation.

I'm creating a site to track issues on several office locations.

So I created
- a custom post type "Issue"
- a custom taxonomy "Location" that holds office location such as "Branch 1", "Branch 2", "Branch 3", etc
- a CRED form to submit issue

On each location, there will be one or more Branch Officers, users that are assigned to submit issues on that location.

There will also a Head Officer, a higher level user who can submit issues on behalf of other user in other location.

Is there a native solution to restrict which Location that can be selected on the CRED form based on logged in user, so that the Head Officer can select one or more locations, while branch officers can only select their own location?

#1107467

Hello,

I assume you are using shortcode [cred_field] to render the "Location" taxonomy field.

There isn't such a built-in feature within Toolset form plugin, see our document:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field

No such a native solution to restrict which Location that can be selected on the CRED form based on logged in user.

As a workaround, you can use generic field shortcode [cred_generic_field] to replace the shortcode [cred_field].

For example:
1) Create some user roles:
- Head Officer
- Branch 1
- Branch 2
...
https://toolset.com/documentation/user-guides/managing-wordpress-admin-capabilities-access/

2) Create a post form for creating the "Issue" post,
In this form, use Access shortcode [toolset_access] to check current user's role, then display different generic field shortcode [cred_generic_field]
https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/
You will need to setup the options of shortcode [cred_generic_field] manually
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_generic_field

3) After user submits the form, use action hook cred_save_data to trigger a custom PHP function
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
in this function, save the generic field value into "Location" taxonomy
https://codex.wordpress.org/Function_Reference/wp_set_object_terms

For your reference.

#1110731

Hi, Luo. First of all, thank you for your response and sorry for not replying sooner.

Secondly, I find your solution too complicated to implement. But since the Location restriction feature is not mandatory, for now we are just showing the field as it is.

I tried looking for plugins that might help me with what I'm trying to achieve, but they are either unmaintained for a very long time or unclear if they support custom posts.

Do you have recommended plugins in mind?

#1111256

No, there isn't other plugin I can recommended, you might consider custom codes, you check it with our experienced contractors:
https://toolset.com/contractors/

#1111286

I will consider that.

Thank you for your help.