Please don't mark this as already asked question as I have searched all the questions and none of them gives a clear answer.
So I have created a custom role through Members plugin and I want the user with custom role 'Society Manager'to edit the custom post type post only and dont let them create new one. Admin should still be allowed to create new posts.
I have seen others using css/html and Jquery to remove the Add New button but it's not a good choice. The problem is I dont see create_posts option in Members plugin. So can anyone please help me solve this issue in detail? This is my custom post type code.
register_post_type('society' , array(
'show_in_rest' => true,
'capability_type' => 'society',
'map_meta_cap' => true,
'capabilities' => array(
'create_posts' => 'do_not_allow',
),
'supports' => array('title','thumbnail','author'),
'rewrite' => array('slug' => 'societies'),
'has_archive' => true,
'public' => true,
'labels' => array(
'name' => 'Societies',
'add_new_item' => 'Add New Society',
'edit_item' => 'Edit Society',
'all_items' => 'All Societies',
'singular_name' => 'Society'
),
'menu_icon' => 'dashicons-buddicons-groups'
));
You can see there is no option to deny create_posts in members plugin
register_post_type
, or rather that's not what it means. You're telling it what capability it is, not what it isn't. I'm not sure it's possible to only edit and not create, editing vs adding in WP is very similar with very few differences between the two