WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom Post Type show_in_menu permissions (3 posts)

  1. Raymond Hill
    Member
    Posted 2 years ago #

    I've created a custom post type and set show_in_menu to a string of another custom post type so that the admin menu shows:

    Custom Post Type
    -> All Posts
    -> Add Post
    -> All Second Custom Post Types

    The user account can access the second custom post type listing page.

    The user account gets "You do not have sufficient permissions to access this page." when clicking "Add Second Custom Post Type"

    The user capabilities do not include general edit_post or edit_page... only capabilities specific to the custom post type and second custom post type... along with read and upload from the core.

    I've narrowed down that a call to user_can_access_admin_page() is where the failure occurs. Even moreso it appears to be in the file /wp-admin/includes/plugin.php around lines 1545-1550 where it is looping through $_wp_submenu_nopriv array.

    Any help would be appreciated. I've been trying to understand why this supported feature "show_in_menu" has been failing to allow the user to create a new custom post.

    Thank you,
    Ray

  2. Raymond Hill
    Member
    Posted 2 years ago #

    Figured out a solution...

    From what I was able to gather, even if the user has the capability to create new custom posts, if there isn't a link in the admin submenu than wordpress will prevent the user from doing so.

    So, while show_in_menu adds a link for listing the existing custom posts, it doesn't add a link to add new custom posts.

    [Code moderated as per the Forum Rules. Please use the pastebin]

    I hope this helps someone else out... sorry if it isn't the clearest way of explaining things.

  3. Cerealfreak
    Member
    Posted 2 years ago #

    Hello

    I've the same problem, but i cannot figure out a solution. Can u please post some code that solve the issue?

    tnx in advance,
    gabriele

Topic Closed

This topic has been closed to new replies.

About this Topic