Capabilities for custom taxonomies
-
Heya!
I’ve been using this plugin happily for some time now but found only recently the need to give custom user roles the rights to assign terms from custom taxonomies.
I tried to fiddle around with the ‘cptui_pre_register_taxonomy’ filter hook but only broke just about everything I could while trying (fixed it again but leaving the hook alone ?? so no problem there)
but the only solution I finally found was directly editing the plugin files. As that means I will lose my functionality everytime the plugin updates, I thought I’d throw my solution in here and hope it (or something similar) might maybe get into the original code.
So what I did was:
I added ‘capabilities’ to the register_taxonomy $args variable in custom-post-type-ui.php (line 279):
$args = array( 'labels' => $labels, 'label' => $taxonomy['label'], 'hierarchical' => get_disp_boolean( $taxonomy['hierarchical'] ), 'show_ui' => get_disp_boolean( $taxonomy['show_ui'] ), 'query_var' => $taxonomy['query_var'], 'rewrite' => $rewrite, 'show_admin_column' => $show_admin_column, 'capabilities' => array( 'edit_terms' => 'edit_' . $taxonomy['name'], 'delete_terms' => 'delete_' . $taxonomy['name'], 'assign_terms' => 'assign_' . $taxonomy['name'], ) );
Now all my custom taxonomies can still managed by the administrator, but I can assign edit, delete and assign rights to (custom) user roles.
If that functionality is un-needed but the plugin, I’ll just copy my bit of code back into it after every update, no worries ??
Thanks again for a great plugin!
- The topic ‘Capabilities for custom taxonomies’ is closed to new replies.