#41343 closed defect (bug) (invalid)
Multisite issue: Applying remove_submenu_pages($parent_slug, $menu_slug) to a page like admin.php?page=qs takes out all sub menus under that parent
Reported by: | subrataemfluence | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.8 |
Component: | Administration | Keywords: | |
Focuses: | ui, administration, multisite | Cc: |
Description
Hi,
Having strange issue with admin menu in multisite environment. I have a menu which has two sub-menus, YRC Global Settings (first on the list) and YRC Homepage Settings (second in the list). The parent and sub-menus are all pointing to admin.php?page=qs
, qs being different for teh second sub-menu in the list.
I required to hide the second sub-menu item keeping the first one visible, so that when admin/user hovers on the parent menu i.e. YRC Settings, the first one (YRC Global Settings) only flies out keeping the other one in the list invisible.
I used remove_submenu_page( 'yrc_settings', 'yrc_home_settings' );
, but this takes out both sub when in multisite mode but in single installation mode it works fine.
Menu structure is like this:
Parent: YRC Settings
Pointing to: /wp-admin/admin.php?page=yrc_settings
First Sub menu item: YRC Global Settings:
Pointing to: /wp-admin/admin.php?page=yrc_settings
Second Sub menu item: YRC Homepage Settings
Pointing to: /wp-admin/admin.php?page=yrc_home_settings
I am not sure if this is a multisite specific bug, but because the same approach works well with single installation then either this is a bug or there is not enough or no documentation about how to use this function in multisite mode!
Either way I feel this should be looked into.
The code in functions.php
file looks like this:
<?php function restrict_admin_access_by_role() { if(function_exists('remove_menu_page')) { if(is_multisite()) { if(!is_super_admin()) { remove_submenu_page( 'yrc_settings', 'yrc_home_settings' ); } } } } add_action('admin_menu', 'restrict_admin_access_by_role', 999);
This is how the menu looks like for admin