Adding a menu to the new network admin

Adding a menu to the new network admin

Coming in 3.1, the Super Admin menu will be shuffled off to its own admin area, thus making the distinction really clear between global network actions and site-specific ones. I wrote about this back here.

"But Andrea," some of you have said, "My menus for my plugin are in the wrong place, how do I fix it?" Fear not, for I have hunted down a lovely example for you.

Note in the trunk version of the domain mapping plugin (revision 316597) there is support to add that plugin's menus to the network admin area. Settings is a good spot.

[php]
function dm_network_pages() {
add_submenu_page('settings.php', 'Domain Mapping', 'Domain Mapping', 'manage_options', 'dm_admin_page', 'dm_admin_page');
add_submenu_page('settings.php', 'Domains', 'Domains', 'manage_options', 'dm_domains_admin', 'dm_domains_admin');
}
add_action( 'network_admin_menu', 'dm_network_pages' );

[/php]

The action you're going to use now and in the future is network_admin_menu. Add to whatever menu area you deem appropriate. What used to be submenu items in Super Admin is mostly a top-level menu item in network admin. Snazzy stuff.

4 Comments
  • Gary
    Posted at 07:20h, 01 December Reply

    You can simplify the code by using the add_options_page() wrapper function.

    • Ron
      Posted at 14:16h, 29 May Reply

      Both of the menu items appear in network admin vs site admin.

  • Marcel
    Posted at 18:04h, 30 January Reply

    Shouldn’t the capability be ‘manage_network’ in stead of ‘manage_options’?

    • Ron
      Posted at 14:17h, 29 May Reply

      A user only has access to network admin if they have the manage_network permission. So the permission requested for the menu item isn’t important in this instance.

Post A Comment