Add capability to a role , so user is only able to view his own posts

First of all you need to remove capability edit_others_posts if assigned to vendor role. Then use the code snippet given below: function posts_for_current_author($query) { global $pagenow; if( ‘edit.php’ != $pagenow || !$query->is_admin ) return $query; if( !current_user_can( ‘edit_others_posts’ ) ) { global $user_ID; $query->set(‘author’, $user_ID ); } return $query; } add_filter(‘pre_get_posts’, ‘posts_for_current_author’); Above code allows … Read more

WordPress remove capability post ,media completely for custom role

Remove a top level admin menu: function custom_menu_page_removing() { remove_menu_page( $menu_slug ); } add_action( ‘admin_menu’, ‘custom_menu_page_removing’ ); To remove only certain menu items include only those you want to hide within the function. To remove menus for only certain users you may want to utilize current_user_can(). You can take a look at https://codex.wordpress.org/Function_Reference/remove_menu_page

How to get all capabilities

First, create [all-capabilities] shortcode. Put this code in your theme’s functions.php: function wpse_all_capabilities() { $out=”<style> .flex-columns { column-count: 4; column-gap: 3em; column-rule: 1px solid #000; } </style>”; $out .= ‘<p class=”flex-columns”>’; $users = get_users(); foreach ( $users as $user ) { if ( $user->caps[‘administrator’] ) { $allcaps = array_keys( $user->allcaps ); foreach ( $allcaps as … Read more