admin管理员组

文章数量:1026423

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

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

Share Improve this question edited Mar 28, 2019 at 10:14 Pratik Patel 1,1111 gold badge11 silver badges23 bronze badges asked Mar 28, 2019 at 10:01 Sándor KerekesSándor Kerekes 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

Found the Bug. On the custom post type, the guttenberg editor was activated by : 'show_in_rest' => true. This was blocking the featured image to show up. Removing the guttenberg fix the problem. With the classic editor the featured image is showing on the edit page.

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

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

Share Improve this question edited Mar 28, 2019 at 10:14 Pratik Patel 1,1111 gold badge11 silver badges23 bronze badges asked Mar 28, 2019 at 10:01 Sándor KerekesSándor Kerekes 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

Found the Bug. On the custom post type, the guttenberg editor was activated by : 'show_in_rest' => true. This was blocking the featured image to show up. Removing the guttenberg fix the problem. With the classic editor the featured image is showing on the edit page.

本文标签: