The MU forums have moved to WordPress.org

question about disabling plugins menu for everyone except super admin (7 posts)

  1. dwenaus
    Member
    Posted 14 years ago #

    hi, I'm using the dsaders great Menus plugin to control the menu for all blog users. everything works well except the plugins menu. It seems that that plugin is using the default usage of hiding the plugins menu, which when clicked hides that menu even for the wpmu site admin (super admin).

    Is there any way to get the plugin menu hidden for everyone, such as sub blog admins, but not the site admin?

    thanks again illustrious dsader!

    D

  2. dsader
    Member
    Posted 14 years ago #

    The Menus plugin does nothing to the Plugins menu.

    A bit of editing to the function wpmu_menu() in mu.php to unset the plugins menu for non SiteAdmins only will be needed.

    if( $menu_perms[ 'plugins' ] != 1 ) {
    	if( !is_site_admin() ) {
    		unset( $menu['45'] ); // Plugins
    		unset( $submenu[ 'plugins.php' ] );
    	}
    }

    Then change the top of the plugins.php to something like

    if( ( !is_site_admin() ) && ($menu_perms[ 'plugins' ] != 1 ) ) . . .

  3. dwenaus
    Member
    Posted 14 years ago #

    thanks for the speedy reply. Are you referring to the mu.php in /wp-admin/includes/ ?

    Excuse my ignorance, but isn't editing core files a no-no? maybe i'm missing something obvious here?

    thanks,
    Deryk

  4. dsader
    Member
    Posted 14 years ago #

    There is an obvious hook to replace, or remove_action, the entire wpmu_menu(from /wp-admin/includes/mu.php) and add_action('_admin-menu',''your_menu");

    However, it is not obvious how a plugin gets around the permission check at the top of the plugin.php file. You'll be hard coding your change there anyway.

  5. PerS
    Member
    Posted 14 years ago #

    this will be in the next release

  6. dwenaus
    Member
    Posted 14 years ago #

    thanks. this code did the trick to hide the menu.

    function hide_plugin_menu() {
    	global $menu, $submenu;
    
    	if( !is_site_admin() ) {
    		unset( $submenu['plugins.php'][5] );
    		unset( $menu['35'] ); // Plugins
    	}
    }
    add_action( '_admin_menu', 'hide_plugin_menu' );

    seeing as my site's backend will be used in a closed community, I don't have to worry about people accessing the plugins page that way.

    but i'm looking forward to the plugin manager soon to come from the awesome buddypress project!

  7. dwenaus
    Member
    Posted 14 years ago #

    a slight corretion to the above code. the last line works better as:

    add_action( 'admin_menu', 'hide_plugin_menu' );

    on all installs of wpmu, this action (without the _) is called after the wpmu_menu() function. wheras if you use _admin_menu sometimes it is after and sometimes not. weird but true.

About this Topic