How to assign multiple roles for capabilities array withini register_taxonomy function?

I am not sure how to add multiple capabilities to ‘assign_terms’ capability.

My code is below, notice the capabilities array within the register_taxonomy function

/* Registers taxonomies. */

function cflnk_wod_score_register_taxonomies() {
/* Set up the artist taxonomy arguments. */
$wod_name_args = array(
    'hierarchical' => false,
    'query_var' => 'wod_name', 
    'show_tagcloud' => true,
        'rewrite' => array(
            'slug' => 'wod/name',
            'with_front' => false 
            ),
    here --->>> 'capabilities' => array (
            'manage_terms' => 'administrator',
            'edit_terms' => 'administrator',
            'delete_terms' => 'administrator',
            'assign_terms' => 'administrator', 'editor', 'author', 'contributor'
            ),
    'labels' => array(
        'name' => 'WOD Names',
        'singular_name' => 'WOD Name',
        'edit_item' => 'Edit WOD Name',
        'update_item' => 'Update WOD Name',
        'add_new_item' => 'Add New WOD Name',
        'new_item_name' => 'New WOD Name Name',
        'all_items' => 'All WOD Names',
        'search_items' => 'Search WOD Names',
        'popular_items' => 'Popular WOD Names',
        'separate_items_with_commas' => 'Separate wod names with commas',
        'add_or_remove_items' => 'Add or remove wod names',
        'choose_from_most_used' => 'Choose from the most popular wod names',
    ),
);

Related posts

Leave a Reply

1 comment

  1. When assigning capabilities to ‘capabilities’ argument of register_taxonomy() you need to assign the capability and not the role! so use capabilities that only a specific role has eg:

    'capabilities' => array (
                'manage_terms' => 'manage_options', //by default only admin
                'edit_terms' => 'manage_options',
                'delete_terms' => 'manage_options',
                'assign_terms' => 'edit_posts'  // means administrator', 'editor', 'author', 'contributor'
                )