Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #8045

    I have granted access to “edit_cpts” but the user cannot edit custom post types unless I also give them “edit_posts”.

    But I don’t want them to be able to edit regular posts, I ONLY want them to be able to edit custom post types.


    I think this might be caused by a custom script I have, I’ll look into it and update


    Ok, so my custom script is what’s breaking this.

    Here’s my script:

    add_action( ‘admin_menu’, ‘register_my_page’ );
    function register_my_page() {
    add_menu_page( ‘Dept Pages’, ‘Dept Pages’, ”, ‘dept_pages_menu’, ”, ‘dashicons-arrow-right’ );


    I’m trying to organize all my custom post types into a menu called “Dept Pages”. This script does that, but when I have this script running, my permissions break.


    This problem is not related directly to the user permissions. But comes from how WordPress checks if user has access to the an admin page. WP checks if user has access to the admin menu item correspondent to the admin page, but if it’s not defined shows the access error message event if user has full access to this custom post type.
    at the end of wp-admin/includes/menu.php:

    if ( ! user_can_access_admin_page() ) {
    	 * Fires when access to an admin page is denied.
    	 * @since 2.5.0
    	do_action( 'admin_page_access_denied' );
    	wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
    $menu = add_menu_classes( $menu );

    You can find function user_can_access_admin_page() at wp-admin/includes/plugin.php file and look how many criteria WP checks for admin page access, not only related user capability.

    You need to investigate how correctly define admin menu to show custom post type from there, not from the default WP menu for CPT. May be look to some other plugin code, which make something similar.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.