I need to hide menu items and plugins from superadmin's on my Multi-Network install

Hello support, long time no chat again :slight_smile:

I hope you're all doing well tonight :slight_smile:

I have a high-end issue I'm hoping you can help me with. This is a two part interrelated issue.

#1 When I activate WPMUdev Dashboard it can only be seen by me and no other SuperAdmin's (Awesome) However, the plugin can still be seen in the plugin's directory. (Not so awesome) :slight_smile: I know I can hide this through either css or functions.php but I'm not sure how to best do this. Can you help?

Which leads me to Issue #2

When I setup a network site, I want to have specific plugins that are activated by the primary superadmin only visible to the primary superadmin. Menu item and plugin. Anyone here have experience with this? Your help would be awesome :slight_smile:

p.s. I plan on using https://wordpress.org/plugins/functionality/ to launch any script that might normally go in the functions.php file so I can manage it site-wide and don't need to worry about it blog by blog or user by user... Help?

Thanks!!

  • Ash

    Hello @sdinvestor2k

    I hope you are well today and thanks for asking the question.

    For #1 use this:

    add_action( 'admin_head', 'hide_wpmu_plugin' );
    function hide_wpmu_plugin() {
    	if( ! is_super_admin() ){
    	?>
    	<style>
    		tr#wpmu-dev-dashboard{display: none;}
    	</style>
    	<script type="text/javascript">
    	jQuery(function($){
    		var obj = $('tr#wpmu-dev-dashboard');
    		obj.next('tr.plugin-update-tr').remove();
    		obj.remove();
    	});
    	</script>
    	<?php
    	}
    }

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    #2: I don't have any experience with this. But if you network activate a plugin, that plugin should not be available in the subsite plugin list. Would you please rephrase this part? :slight_smile:

    Using plugin to write code is risky sometimes. Suppose you have a function called mytest() in somewhere, could be in any plugin or theme. Now you have declared same function in that snippet plugin, the site will be down right then. It's always good practice to use mu-plugins to auto activated for all sites.

    Cheers
    Ash

  • SD2k

    Thank you very much for your help @Ashok,

    Let me clarify...

    Everything I'm referring to is regarding the Network Dashboard side of the site, not the standard dashboard.

    When One SuperAdmin activates WPMU DEV Dashboard plugin, no other SuperAdmin's can see the menu item. (This is standard and this is how we want to keep it.)

    However, Other SuperAdmin's can still see and/or deactivate the plugin from the Network Dashboard Side. I would like to hide the plugin entirely from other SuperAdmin's on the Network Dashboard Side so the only SuperAdmin that can see it is the SuperAdmin who activated it. The script above didn't do that. Is there code that needs to go before or after it that I'm missing?

    #2 Is exactly the same. I would like to have one Master SuperAdmin. When (whatever superadmin I choose) activates network wide plugins, I don't want any other superadmins to see those plugins or to have access to them whatsoever. I would like the menu to be hidden and the actual plugin in the directory to be hidden. "From the network dashboard side"

    I'm very familiar with multisites and the mu-plugin's directory but either I placed the code you sent me in the wrong place or there's an argument missing from it.

    I first created my own admin-manager.php file then I added it to the mu-plugins.php file and I also tried it at the end of the functions.php file for the twenty-fourteen theme but nothing changed.

    I hope this helps you understand what I'm trying to do!

    Thanks :slight_smile:

  • Ash

    Hello @sdinvestor2k

    I hope you are well today.

    Now I see what you mean. I don't think this is possible easily. Because it has to be done for every plugin.

    I am not quire sure though, but I am tagging an available developer from second level support line in this thread for his valuable opinion on this issue. Please note that, developer response might be slower than usual staff response, so we appreciate your patience on this.

    Cheers
    Ash

  • Hoang Ngo

    Hi @sdinvestor2k,

    I hope you are well today.

    Actually, there's no different role from super admin and the site owner, both are super admin, so we can only make this to work by user_id.

    So for the #1

    add_action('admin_head', 'remove_dashboard_widget');
    function remove_dashboard_widget()
    {
        $super_admin_id = 1;
        if (get_current_user_id() != $super_admin_id) {
            ?>
            <style type="text/css">
                #wpmudev_widget {
                    display: none;
                }
            </style>
        <?php
        }
    }

    Please update the $super_admin_id variable to your need.
    #2, just for clarify, so you want to hide the plugins link from the network admins to all of other admins except the site owner?

    Please advise,
    Thanks!

    Best regards,
    Hoang Ngo

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.