[wp-trac] [WordPress Trac] #41343: 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

WordPress Trac noreply at wordpress.org
Mon Jul 17 12:43:36 UTC 2017


#41343: 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
-------------------------------------------+-----------------------------
 Reporter:  subrataemfluence               |      Owner:
     Type:  defect (bug)                   |     Status:  new
 Priority:  normal                         |  Milestone:  Awaiting Review
Component:  Administration                 |    Version:  4.8
 Severity:  normal                         |   Keywords:
  Focuses:  ui, administration, multisite  |
-------------------------------------------+-----------------------------
 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
 <?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);
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41343>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list