How do you add custom taxonomy capabilities exactly?

I can’t see to get it. The capabilities fail to appear when using plugins like “Capability Manager” or “Members” to view a list of available capabilities.

This is the code I’m attempting to use:

Read More
add_action( 'init', 'register_taxonomy_spot_tag' );

function register_taxonomy_spot_tag() {

    $labels = array( 
        'name' => _x( 'Spot Tags', 'spot tag' ),
        'singular_name' => _x( 'Spot Tag', 'spot tag' ),
        'search_items' => _x( 'Search Spot Tags', 'spot tag' ),
        'popular_items' => _x( 'Popular Spot Tags', 'spot tag' ),
        'all_items' => _x( 'All Spot Tags', 'spot tag' ),
        'parent_item' => _x( 'Parent Spot Tag', 'spot tag' ),
        'parent_item_colon' => _x( 'Parent Spot Tag:', 'spot tag' ),
        'edit_item' => _x( 'Edit Spot Tag', 'spot tag' ),
        'update_item' => _x( 'Update Spot Tag', 'spot tag' ),
        'add_new_item' => _x( 'Add New Spot Tag', 'spot tag' ),
        'new_item_name' => _x( 'New Spot Tag Name', 'spot tag' ),
        'separate_items_with_commas' => _x( 'Separate spot tags with commas', 'spot tag' ),
        'add_or_remove_items' => _x( 'Add or remove spot tags', 'spot tag' ),
        'choose_from_most_used' => _x( 'Choose from the most used spot tags', 'spot tag' ),
        'menu_name' => _x( 'Spot Tags', 'spot tag' ),
    );

    $args = array( 
        'labels' => $labels,
        'public' => true,
        'show_in_nav_menus' => true,
        'show_ui' => true,
        'show_tagcloud' => true,
        'hierarchical' => false,

        'rewrite' => true,
        'query_var' => true,
        'capabilities' => array(
            'manage_terms' => 'manage_spot_tags',
            'edit_terms' => 'edit_spot_tags',
            'delete_terms' => 'delete_spot_tags',
            'assign_terms' => 'assign_spot_tags'
        )
    );

    register_taxonomy( 'spot_tag', array('spot'), $args );
}

I generated the above code with this tool:
http://themergency.com/generators/wordpress-custom-taxonomy/

Related posts

Leave a Reply

2 comments

  1. This is really old, but number uno hit on my google search, I found the anwser to be.

    You don’t need to pre add the capabilities, just add “, ‘map_meta_cap’ => true” to you above code like so

    $args = array( 
        'labels' => $labels,
        'public' => true,
        'show_in_nav_menus' => true,
        'show_ui' => true,
        'show_tagcloud' => true,
        'hierarchical' => false,
    
        'rewrite' => true,
        'query_var' => true,
        'capabilities' => array(
            'manage_terms' => 'manage_spot_tags',
            'edit_terms' => 'edit_spot_tags',
            'delete_terms' => 'delete_spot_tags',
            'assign_terms' => 'assign_spot_tags'
        ), 
        'map_meta_cap' => true
    );
    

    This will make it add the capabilities seamlessly