Here is what I did, instead of granting subscriber all these permission, I upgraded all my subscribers to contributor.
I changed the capability of my custom post type to:
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'boat' ),
'capability_type' => 'post',
'capabilities' => array(
'publish_posts' => 'edit_posts',//contributor can edit
'edit_others_posts' => 'update_core',//administrator can see other
'delete_posts' => 'update_core',//administrator can see other
'delete_others_posts' => 'update_core',//administrator can see other
'read_private_posts' => 'update_core',//administrator can see other
'edit_post' => 'edit_posts',//contributor can edit
'delete_post' => 'update_core',//administrator can see other
'read_post' => 'edit_posts',//contributor can edit
),
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title','revision' )
);
register_post_type("boat", $args);
Then I added some custom function I found at different webpage :
This one hide the menu I dont want the contributor to see
source : source 1
and : source 2
function remove_menus(){
$author = wp_get_current_user();
if(isset($author->roles[0])){
$current_role = $author->roles[0];
}else{
$current_role = 'no_role';
}
if($current_role == 'contributor'){
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'edit.php?post_type=my_other_custom_post_type_I_want_to_hide' );
}
}
add_action( 'admin_menu', 'remove_menus' );
Then I restricted contributor from seings other post with :
from : source 3
add_action( 'load-edit.php', 'posts_for_current_contributor' );
function posts_for_current_contributor() {
global $user_ID;
if ( current_user_can( 'contributor' ) ) {
if ( ! isset( $_GET['author'] ) ) {
wp_redirect( add_query_arg( 'author', $user_ID ) );
exit;
}
}
}
And finally I allowed contributor to upload file with :
from source 4
add_action('admin_init', 'allow_contributor_uploads');
function allow_contributor_uploads() {
$contributor = get_role('contributor');
$contributor->add_cap('upload_files');
}
Since I got a bunch of custom field in my custom post type I made with ACF (Advance custom field) I restricted the media upload to only local post so my contributor cant use media from other people.
I hope this will help someone! :)