Capabilites not working [closed]
Capabilites not working [closed]
Capabilites not working [closed]
How to restrict access to specific pages on the back-end?
You are using the right WP function but unfortunately not passing the right parameter to make this work for you. current_user_can() accepts capabilities as well as roles as parameters. In the above you are using roles and not capabilities. You can use capabilities to make it work. For example, if you want the minimum privilege … Read more
Allow Block Editing By User Role
Maybe this was some conflict plugin/functions.php/theme/WP-version… I just duplicated the editor role with User Role Editor, removed all the delete_*_posts capabilities and the user cannot delete a post.
Share a draft looks like an easy plugin to do this. (Answering my own question after trying a few different things, other suggestions are still welcome.)
UPDATE – this is easy to do with the press permit plugin, I recommend it for any setup like this To get this working I had to do a couple of things: Default all pages/posts/categories ‘revisor’ (via Revisionary plugin) users to be restricted to ‘WP_Administrators’ Create a “User Group” for each department ie: ‘Conference Services … Read more
Add the capabilities to the role. Replace ‘cpt’ with the name of your custom post type: $role = get_role( ‘contributor’ ); $role->add_cap( ‘delete_published_cpt’ ); $role->add_cap( ‘delete_others_cpt’ ); $role->add_cap( ‘delete_cpt’ ); $role->add_cap( ‘edit_others_cpt’ ); $role->add_cap( ‘edit_published_cpt’ ); $role->add_cap( ‘edit_cpt’ ); $role->add_cap( ‘publish_cpt’ ); But you shouldn’t add or remove caps on every page load. That’s why … Read more
First add capabilities to the roles like this add_action( ‘after_setup_theme’, ‘add_caps_to_custom_roles’ ); function add_caps_to_custom_roles() { $caps = array( ‘read_cpt’, ‘edit_cpt’, ‘edit_others_cpt’, ); $roles = array( get_role( ‘third_party’ ), get_role( ‘data_entry_operator’ ), ); foreach ($roles as $role) { foreach ($caps as $cap) { $role->add_cap( $cap ); } } } THEN /** * Helper function getting roles … Read more
The code below adds the counts for user roles. It’s commented pretty well to explain what’s happening. It should give you a good starting point for further customization (maybe you want to hide 0 counts, change the HTML output, etc.). function comments_shortcode($atts) { $current_user = wp_get_current_user(); extract( shortcode_atts( array( ‘id’ => ” ), $atts ) … Read more