map_meta_cap woes
In the end I found this plugin that did the job in two seconds. http://wordpress.org/plugins/map-cap/ . I’m still curious to know how its done but I suppose I can always study the plugin.
In the end I found this plugin that did the job in two seconds. http://wordpress.org/plugins/map-cap/ . I’m still curious to know how its done but I suppose I can always study the plugin.
You could create a new role, say staff, and add the users you want to that specific role. Then link that role a new capability of your choice, e.g. access_staff. Now you have a new role with a new capability, so all you need to do to restrict the access to any part of the … Read more
Well you could do one of the following things; Create a separate page and only display the data (seems to me the best approach) Display the information on user-edit.php and create a hook telling WP that if the user role is Center and is trying to save other user information return an error. It actually … Read more
Ok – lets try this again 🙂 I added the map_meta_cap parameter which is needed to have delete_others_posts work. Now I was able to get authors to edit and view all posts but only delete their own. $labels = array( ‘name’ => __( ‘Book’, ‘textdomain’ ), ‘singular_name’ => __( ‘Book’, ‘textdomain’ ), ‘menu_name’ => __( … Read more
you need to add map_meta_cap => true, in the args of register_post_type ‘publicly_queryable’ => false, ‘map_meta_cap’ => true, ‘capability_type’ => array( ‘lead’, ‘leads’ ), ); register_post_type( ‘leads’, $args );
You haven’t missed any capabilities. User should be able to insert images into the editor with these capabilities. The only problem I can think of is that, you are trying to modify the capabilities of a role which won’t work. See this section If you are defining a custom role, and adding capabilities to the … Read more
The register_post_type() function takes a post type name as argument for map_meta_cap, where the default is post. Take a look at the internals of get_post_type_capabilities() for extended insights. That should help you to understand how it’s meant to be: function get_post_type_capabilities( $args ) { if ( ! is_array( $args->capability_type ) ) $args->capability_type = array( $args->capability_type, … Read more
Man. This was not easy to chase down. The answers up above absolutely do not work unless you give the user’s role very broad “manage_options” capability. I asked (and answered) the Trac issue here: Admin custom option screen not saved unless user manage_options capability Anyone in the future who might search/read this – the trick … Read more
use the profile_update hook and in the hooked function, run this check to make sure that it’s adding the previous data to the users profile on update too. if ( $update ){ do_action(‘profile_update’, $user_id, $old_user_data); }else{ do_action(‘user_register’, $user_id); } return $user_id; This answer can help you understand it more: WordPress edit_user_profile_update update secondary role
No there isn’t anything built into the core WordPress, I would recommend this plugin: https://wordpress.org/plugins/user-roles-and-capabilities/screenshots/ Or you would use PHP to add a capability to a specific role (or user): https://codex.wordpress.org/Function_Reference/add_cap