2

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/

1

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..

| improve this answer | |
  • Thanks for the reply. I already saw that. The code I used in the example was generated at themergency.com/generators/wordpress-custom-taxonomy. It seems to work very nicely for adding post types (capabilities are added automatically). But I guess that's not the case with taxonomies (as the site obviously claims with the automatic generator). – trusktr Jul 1 '11 at 6:24
  • I see if I can create the capability first and see what happens... – trusktr Jul 1 '11 at 6:24
-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

| improve this answer | |
  • Hi, thanks for contributing but according to the developer docs developer.wordpress.org/reference/functions/register_taxonomy , register_taxonomy doesn't have a map_meta_cap argument. register_post_type does, but its purpose is not to make third party plugins show checkboxes for capabilities, but to toggle which base capabilities are used to construct meta capabilities such as edit_post. – Andy Macaulay-Brook Nov 8 '16 at 11:08

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.