Remove Capabilities from WP admin for specific user role

You can add a condition on capabilities in order to exclude the admin from the unset action for example add_filter( ‘post_row_actions’, ‘remove_row_actions’, 10, 2 ); function remove_row_actions_staff( $actions, $post ){ //This line stops function execution if user has some admin capabilities if( current_user_can( ‘administrator’ ) ): return $actions; endif; if( $post->post_type() === ‘wiki-testimonials’ ) unset( … Read more

Add, edit specific CPT with custom role

There’s no such hook named load-themes.php in WordPress. One of the hooks you can use to add custom capabilities is after_setup_theme. Also, there’s no need to use ‘themes.php’ == $pagenow && isset($_GET[‘activated’]) condition there. What are you trying to achieve this way? Try to use this code instead: add_action( ‘after_setup_theme’, function() { $role = get_role( … Read more

Allow Contributor to edit published post and filter by page id

You can use user_has_cap filter to check and grant capabilities dynamically. add_filter(‘user_has_cap’, ‘contributor_can_edit_published_posts’, 10, 4); function contributor_can_edit_published_posts($allcaps, $caps, $args, $user) { global $post; // Do we have a post? if ( ! $post ) { return $allcaps; } // Is the user a contributor? if ( ! isset( $allcaps[‘contributor’] ) || true !== $allcaps[‘contributor’] ) … Read more

WordPress bug with capabilities?

Activate the plugin again, reset your caps to default. I guess the problem is the plugin – not wp. Maybe it misses to add some capability. Best would be to try to take a look at the capabilites that are assigned to the different roles. How-to inspect current user data the smart way Create an … Read more