Custom Taxonomies Cababilities

Hi @curtismchale: Try ‘river-class’ instead of ‘Class’, i.e.: register_taxonomy( ‘river-class’, array( ‘fvww-river-guide’ ), array( ‘hierarchical’ => true, //operates like a category ‘labels’ => $labels, ‘rewrite’ => true, ‘public’ => true, ‘show_ui’ => true, ) ); // ends class taxonomy Actually what caused you to stumble was your choice of a capitalized taxonomy name (i.e. “Class” … Read more

How to show a admin bar menu item only to users with certain capabilities?

The check will be called too early if you just write it in your plugin file like this: if ( current_user_can( ‘add_movies’ ) ) { add_action( ‘admin_bar_menu’, ‘wpse17689_admin_bar_menu’ ); } function wpse17689_admin_bar_menu( &$wp_admin_bar ) { $wp_admin_bar->add_menu( /* … */ ); } Because it will execute when your plugins is loaded, which is very early in … Read more

Prevent Editors from Editing/Deleting Admin Accounts

There is a function WordPress uses called get_editable_roles, which is (I think) used to determine which roles a particular user can edit. The source for this function looks like this: function get_editable_roles() { global $wp_roles; $all_roles = $wp_roles->roles; $editable_roles = apply_filters(‘editable_roles’, $all_roles); return $editable_roles; } So, it looks like you may be able hook into … Read more

How to safely allow user upload on CPTs?

If I understood correctly the situation described in the question and its comments, the user has capabilities to upload files and to edit your post type, so you shouldn’t be fitering capabilities, the user already has the correct capabilities. The problem is that wp_editor() use the global $post by default, and in your context the … Read more

Update User Role

Off the top of my head, you should be able to do something like this: $role = get_role( ‘client’ ); if ( $role && $role->has_cap( ‘install_plugins’ ) ) { // Role not updated yet, so update it. $role->remove_cap( ‘install_plugins’ ); } get_role() returns a WP_Role object on success and WP_Role::remove_cap() calls WP_Roles::remove_cap(), which directly updates … Read more

Hide menu item based on user’s custom capability

This plugin provides filter to manage the menu item by meta value: function custom_menu_item_visibility( $visible, $item ){ if( isset( $item->roles ) ){ $user_id = get_current_user_id(); $user_meta = get_user_meta( $user_id, ‘your-meta-key’, true ); if ( /* your condition */ ){ $visible = true; } else { $visible = false; } } return $visible; } add_filter( ‘nav_menu_roles_item_visibility’, … Read more