The default taxonomy, category. By default, only those with the edit_posts
capability can assign categories during post creation/editing.
I have a role with very limited capabilities. I want to let users in this role be able to assign categories during custom-post-type creation/editing, but I cannot give them the edit_posts
capability and they should not be able to edit the taxonomy, only assign it.
How can I do this? Setting 'assign_terms' => 'read'
is one option, but how can I set that value without having to re-register the taxonomy?
Or alternatively, how can I give my low-level role permission to assign the taxonomy?
This should works
I just found this question and although it might work, I was not satisfied with the solution. There had to be a better way to do this, without registering the taxonomy again. And there is a better solution, I am now using in my CPT plugin.
In this example, I set the
assign_terms
capability for the custom post typecpt_item
to the custom capabilityedit_cpt_items
which enables any user with this capability to assign categories to the CPT.I hope this cleaner solution also works for you.
You could also filter core’s category args before the taxonomy is registered: