No permissions to add new post with a custom post type inside a menu.
-
Hello all,
I’ve been searching for a solution for the past 2 days and had no luck yet.. Also found this problem writen by other people, but no answers.
I want to group my custom post types into a menu in the back-end, and what it seems to be a simple taks…it’s not ??
I know you can create a menu with add_menu_page and then create a custom post type with show_in_menu to append to that menu. That works greate. The CPT is added to the menu and i can see the listing with no problem.
Now the problem is: if i am an administrator i can click “Add New Post” and it works great, but if i’m not (even when i give the menu and post type the right capabilities) it says i have no permission to see that page.
If i dont use “show_in_menu” it create a new menu in the backend with the link “Add New” and it works good. But once i add it to a menu, it says i have no permissions.
Please does someone tried this allready and can help me? It seems a simple “job” for wordpress but it’s frustrating ??
Here is my code:
Created the menu:
add_menu_page( 'Call of Duty 4', 'CoD4 Team', 'edit_kposts', 'cod4team');
Created the post type:
register_post_type( 'cod4_news', array( 'labels' => array( 'name' => 'News' , 'singular_name' => 'News', 'add_new' => 'New News', 'add_new_item' => 'New News' ), 'public' => true, 'has_archive' => true, 'show_ui' => true, 'show_in_menu' => 'cod4team', 'query_var' => true, 'rewrite' => array('slug' => 'cod4_news'), 'supports' => array('title','editor','author','comments'), 'capabilities' => array( 'edit_post' => 'edit_kpost', 'delete_post' => 'delete_kpost', 'read_post' => 'read_kpost', 'publish_posts' => 'publish_kpost', 'edit_posts' => 'edit_kposts', 'edit_others_posts' => 'edit_others_kposts', 'delete_posts' => 'delete_kposts', 'delete_others_posts' => 'delete_others_kposts', 'read_private_posts' => 'read_private_kposts') ) );
Create the Site Manager role:
add_role( 'site_manager', 'Site Manager', array( 'edit_kpost' => true, 'delete_kpost' => true, 'read_kpost' => true, 'publish_kpost' => true, 'edit_kposts' => true, 'edit_others_kposts' => true, 'delete_kposts' => true, 'delete_others_kposts' => true, 'read_private_kposts' => true, 'read' => true, 'upload_files' => true ));
So, using a user with the role “Site Manager” i cant access the new post page, but with the administrator i can.
I hope that i have explained the problem correctly and sorry for my english if not.
Thanks in advance
- The topic ‘No permissions to add new post with a custom post type inside a menu.’ is closed to new replies.