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 (36)
- 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
2 years 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
2 years ago
- Keywords needs-refresh added
- Milestone changed from 4.2 to Future Release