Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#38902 closed defect (bug) (invalid)

get_admin_page_parent() returns empty string when a top level admin page has no children

Reported by: Taeo Owned by:
Priority: normal Milestone:
Component: Administration Version: 4.6.1
Severity: normal Keywords:
Cc: Focuses:

Description

This is causing user_can_access_admin_page() to incorrectly return false in some situations.

For example, I have a custom post type with a custom capability type. I have a custom user role to which I've assigned the edit_ and edit_others_ primitive capabilities. This correctly gives users with this role access to view and edit posts of this type.

However I needed these users to not be able to create new posts. I discovered that the "Add New" links check for the create_posts capability but create_posts is mapped to edit_posts by default. To get around this I added a filter to add a separate create_posts capability which works exactly as intended.

However, thats when I encountered the above bug. The get_admin_page_parent() function now returns an empty string which in turn causes isset( $_wp_menu_nopriv[$pagenow] ) on line 1717 of /wp-admin/plugin.php to evaluate to true since $pagenow = edit.php and my user does not have the default edit_posts capability - only the custom post edit capability.

Change History (2)

#1 @Taeo
10 years ago

  • Resolutioninvalid
  • Status newclosed

Going to rewrite this bug to address the symptoms that were causing me a problem rather than what I assumed was causing it.

#2 @netweb
10 years ago

  • Milestone Awaiting Review
Note: See TracTickets for help on using tickets.