Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Can I stop my client from adding terms to a certain taxonomy? So that I set up a fixed amount of terms, and that´s what they get to choose from.

Can I remove the menu item for certain taxonomies in the backend? Let´s say I have created two taxonomies, and I want the user to be able to access one of them and the other should be hidden and only show up as options in the editing of posts/pages.

share|improve this question

1 Answer 1

When you registered the taxonomy with register_taxonomy there is a capabilities argument. This takes, an array of the capabilities for this taxonomy. In particular:

  • 'manage_terms'
  • 'edit_terms'
  • 'delete_terms'
  • 'assign_terms'

Associated with each of them should be a capability that it is required to be able to perform that action. For instance to assign_terms usually requires the user to have the capabiliy of edit_posts. You can give the first three some capability (custom or otherwise, manage_options might do) that your clients do not have, but you do. The last can be just edit_posts.

As an example:

 register_taxonomy('mytax',array('post'), array(
   'hierarchical' => false,
   //Other properties...
   'capabilities'=>array(
        'manage_terms' => 'manage_options',//or some other capability your clients don't have
        'edit_terms' => 'manage_options',
        'delete_terms' => 'manage_options',
        'assign_terms' =>'edit_posts'),
   //Other properties...
    ));
share|improve this answer
    
Great, thanks!! –  Johan Dahl Mar 15 '12 at 10:21
    
I've been struggling with getting my custom roles to accept my taxonomy capabilities. I've scoured the web these past couple days and your explanation was the first that really made sense. Thanks for explaining it so clearly! It feels good to finally fix those pesky bugs :) +1 to you, sir –  Kristina Childs Dec 5 '12 at 23:31
    
I may need verification, but being able to 'assign_terms' means that you can create terms. It's too bad you can't limit the assign_terms cap to already existing terms (?) –  AlxVallejo Jul 24 '13 at 18:33
    
@AlxVallejo That's correct. But there's a plug-in which lets you do that: wordpress.org/plugins/manage-tags-capability (I've never used it though) –  Stephen Harris Jul 24 '13 at 21:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.