Registering the custom post type:
$labels = array(
'name' => 'tananyags',
'singular_name' => 'etananyag',
'menu_name' => 'E-Tananyagok',
'name_admin_bar' => 'Add new',
'add_new' => 'Add New',
'add_new_item' => 'Add New Item',
'new_item' => 'New',
'edit_item' => 'Edit',
'view_item' => 'View Item',
'all_items' => 'All',
'search_items' => 'Search',
'parent_item_colon' => 'Parent: ??',
'not_found' => 'No item found',
'not_found_in_trash' => 'No item found in the trash',
);
$args = array (
'labels' => $labels,
'public' => true,
'publicly_quaryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => false,
'hierarchical' => false,
'capability_type' => array('etananyag','tananyags'),
'has_archive' => true,
'menu_position' => 7,
'rewrite' => array( 'slug' => 'etananyag'),
'supports' => array( 'title', 'editor', 'thumbnail'),
'taxonomies' => array( 'category' ),
'menu_icon' => 'dashicons-book-alt',
'show_in_rest' => true,
'capabilities' => array(
'edit_post' => 'edit_etananyag',
'read_post' => 'read_etananyag',
'delete_post' => 'delete_etananyag',
'edit_posts' => 'edit_tananyags',
'edit_others_posts' => 'edit_others_tananyags',
'publish_posts' => 'publish_tananyags',
'read_private_posts' => 'read_private_tananyags',
'read' => 'read',
'delete_posts' => 'delete_tananyags',
'delete_private_posts' => 'delete_private_tananyags',
'delete_published_posts' => 'delete_published_tananyags',
'delete_others_posts' => 'delete_others_tananyags',
'edit_private_posts' => 'edit_private_tananyags',
'edit_published_posts' => 'edit_published_tananyags',
'create_posts' => 'edit_tananyags'
),
'map_meta_cap' => true
);
register_post_type('tananyag', $args);
Creating the new role(almost same as author):
add_role( 'e_tananyag', 'E-Tananyag', array(
'upload_files' => 1,
'read' => 1,
'level_2' => 1,
'level_1' => 1,
'level_0' => 1,
));
Assigning the new role the custom capabilities:
$tananyag_role = get_role('e_tananyag');
$tananyag_role->add_cap('edit_tananyags', true);
$tananyag_role->add_cap('delete_tananyags', true);
$tananyag_role->add_cap('edit_published_tananyags', true);
$tananyag_role->add_cap('publish_tananyags', true);
$tananyag_role->add_cap( 'delete_published_tananyags', true );
$tananyag_role->add_cap( 'read_etananyag', true );
$tananyag_role->add_cap( 'edit_etananyag', true );
$tananyag_role->add_cap( 'delete_etananyag', true );
Everything works fine, the user with the role etananyag can see, edit or modify the ctp, but he can't add featured image at all.
Please help