0

I am trying to set some custom capabilities for a custom taxonomy. I am trying the following:

'capabilities' => array(
    'manage_terms' => 'manage_'.$types,
    'edit_terms' => 'edit_'.$types,
    'delete_terms' => 'delete_'.$types,
    'assign_terms' => 'assign_'.$types
)

where $types is the plural form of the taxonomy slug. This is part of a larger function to programmatically create custom taxonomies.


I am viewing the capabilities using User Role Editor (and have looked in the options table of the DB) and these capabilities are not all created. I can see the caps for edit_terms and delete_terms but none for manage_terms and assign_terms which are the ones I actually need.

I am struggling to see what I am doing wrong so any help would be appreciated, thanks!

2

The array that you pass on taxonomy creation should consist of existing capabilities, it doesn't create them. You'd have to do that manually with add_cap() before registering your taxonomy. Unless you need specific capabilities to vary with each of your new taxonomies it's best to pass existing capabilities like manage_categories or create one set of capabilities, eg manage_custom_taxonomies to cover all of them.

1
  • Thank you, got it working now! The docs are not clear on this and other answers I have seen online implied you could do what I was trying above. Jul 14 '17 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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