User cannot “Add New” for Custom Post Type
-
Hi all,
I’ve created a custom post type “reservations”, which I only want to be accessible by users with the custom capabilities set for the post type.
I created a role named “Reservation Manager” where I have added the capability to both this role and the “administrator” role to have access to the post type to do edits, deletes, publish etc. I created one capability name “manage_reservations” to handle all of this, via post type “capabilities” arg.
With the “Reservation Manager”, I can do edit, deletes, etc, everything except when I click the “Add New” button, it says, “Sorry, you are not allowed to access this page.”.
If I add the “edit_posts” capability to the “Reservation Manager” role, its fine, I get to do the “Add New” stuff. If i also set the “show_in_menu” args to “true”, I can “Add New” posts for the post type, even without adding the “edit_posts” capability to the “Reservation Manager” role.
What am I doing wrong? Everything works fine except “Add New” post for the custom post type.
See below for code snippet of post type args. Please, any help….
// get args $args = [ 'exclude_from_search' => true, 'publicly_querable' => false, 'show_ui' => true, 'show_in_nav_menus' => false, 'show_in_menu' => false, 'show_in_admin_bar' => true, 'map_meta_cap' => true, 'capability_type' => 'reservation', 'capabilities' => [ // meta caps (don't assign these to roles) 'edit_post' => 'edit_reservation', 'read_post' => 'read_reservation', 'delete_post' => 'delete_reservation', // primitive/meta caps 'create_posts' => 'manage_reservations', // primitive caps used outside of map_meta_cap() 'edit_posts' => 'manage_reservations', 'edit_others_posts' => 'manage_reservations', 'publish_posts' => 'manage_reservations', 'read_private_posts' => 'read', // primitive caps used inside of map_meta_cap() 'read' => 'read', 'delete_posts' => 'manage_reservations', 'delete_private_posts' => 'manage_reservations', 'delete_published_posts' => 'manage_reservations', 'delete_others_posts' => 'manage_reservations', 'edit_private_posts' => 'manage_reservations', 'edit_published_posts' => 'manage_reservations', ], ];
- The topic ‘User cannot “Add New” for Custom Post Type’ is closed to new replies.