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?
Forgot to add that I would like to implement this on frontend CRED form
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?
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.
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?
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/