WordPress custom post type capabilities issue


Using WP 5.2.4, I am registering my custom post type with this code:

$args = array(
    'labels'          => $labels,
    'public'          => false,
    'show_ui'         => true,
    'show_in_menu'    => true,
    'query_var'       => true,
    'has_archive'     => false,
    'menu_position'   => null,
    'map_meta_cap'    => false,
    'capability_type' => ['note','notes'],
    'rewrite'         => [ 'slug' => 'note', 'with_front' => false ],
    'supports'        => [ 'editor' ],
    'menu_icon'       => 'dashicons-format-aside',

register_post_type( 'note', $args );

Now I want my custom user role to edit/read/delete this post type. I added this caps to my custom user role:

$role = get_role( 'my_custom_role' );


Everything is OK for the administrator role and post type item shows in the admin menu. For other roles, it shows the admin menu item but in the post type list page give permission error.

cps show in admin menu

but cpt posts list not showin

How can I fix this problem ?

Themesfa 2 years 2020-10-24T18:10:21-05:00 0 Answers 16 views 0

Leave an answer