user_can_admin_menu() is Type-Insensitive for Users who Can't Create Pages
|Reported by:||kevinB||Owned by:||johnbillion|
Utilization of the new separation edit_posts /create_posts capability separation reveals a flaw in admin menu privilege checking.
The issue occurs when:
- For any post type other the "post", the user has $type->cap->edit_posts but not $type->cap->create_posts
- User also does not have a manage_terms capability for any associated taxonomies
In that situation, access to "edit.php?post_type=whatever" fails unless the user has the "edit_posts" cap for the "post" type.
This occurs because:
- wp-admin/includes/menu.php removes solitary submenus that have the same destination as the parent
- get_admin_page_parent() returns nullstring if there is no $submenu item
- user_can_access_admin_page() performs a type-sensitive capability check only if get_admin_page_parent() returns an existing $submenu key.
For now, my plugin workaround is to hook into 'admin_menu' and add a dummy submenu with nullstring caption.
Change History (34)
- Summary changed from user_can_admin_menu() is Type-Insensitive for Users who can't create pages to user_can_admin_menu() is Type-Insensitive for Users who Can't Create Pages
comment:10 @nacin — 2 years ago
- Keywords 3.7-early added
- Milestone changed from 3.6 to Future Release
comment:25 @johnbillion — 8 months ago
- Keywords needs-unit-tests added; 3.7-early removed
- Milestone changed from Future Release to 4.2
- Owner set to johnbillion
- Status changed from new to accepted
comment:28 @DrewAPicture — 6 months ago
- Keywords needs-refresh added
- Milestone changed from 4.2 to Future Release