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:

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/

2 Answers
2

Try using add_cap …. adding new capability and creating the capability first in functions.php, i cant locate anything that says capabilities can be created in registering a taxonomy, but you can certainly assign them there..

Leave a Comment