Hide plugins/updates notifications to everyone except super-admin

Hi there.

Is it possible do hide plugins and updates notifications from everyone except for the super admin?

Thanks for your help!

  • Rupok

    Hi Urbano, hope you had a wonderful day.

    Are you referring to update notification in "Dashboard > Updates" menu and "Dashboard > Plugins" menu? Or you are referring to "Dashboard Notification Popups" ? If you are referring to those menus, you can use Admin Menu Editor plugin. It will allow you to hide certain menus depending on user role.

    If you want to hide the popups, I'm afraid, it won't be possible. Because different plugins will show Notification in different ways.

    I could tell you better about the workaround if I was sure which type of update notification you are referring to. Can you please specify so we can give you exact solution?

    I'm looking forward to hear from you and resolve this issue as soon as possible.

    Have a nice day. Cheers!
    Rupok

  • Rupok

    Hi Urbano, hope you had a wonderful day.

    Yeah, I would suggest this kind of workaround. On your given link, they checked username, rather you can use user role. I've wrote the following code for you to use in a MU Plugin. For creating a MU Plugin, create a folder named "mu-plugins" inside your "wp-content" folder. Then inside that "mu-plugins" folder, create a file with any name and with a .php extension. Now paste the code inside that file and save.

    <?php
    add_action( 'admin_head', 'get_user_role' );
    function get_user_role() {
    	global $current_user;
    	$user_roles = $current_user->roles;
    	$user_role = array_shift($user_roles);
    	if ($user_role != "administrator"){
    	    add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
    	    add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
    	};
    };

    For getting more idea on mu plugins, you can go through this article: http://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    I've not tested the code above. Please note, this is cowboy code to give you idea how this can be done. Please let us know if you are confused or if you have any query. We will be glad to assist further.

    Have a nice day. Cheers!
    Rupok

  • Rupok

    Hi Urbano, hope you had a wonderful day.

    In my above approach, it won't be possible. But if you take a detour, you can check user role first, and then can hide those notice divs with CSS. In that case you can keep messages from your target plugins as different plugins use different class/ID for their notices.

    Please let us know if you have any confusion. We will be glad to help.

    Have a nice day. Cheers!
    Rupok

    • Urbano

      Hello Rupok, thanks again for your patience.

      From the code you provided, do super admin keep seeing update notifications?

      I'm a little lost with the CSS hide. Could you give me an example of a code to block CSS to attach in our previous code?

      In this case, i'm not sure what CSS ID's/Class's will be used by plugins. Is there a way I can block all and allow only some ID's? This way I just need to figure out what ID's are being used by Pro-Sites and Branding plugin.

      Sorry if I miss understood something, but I got lost in your last reply. :stuck_out_tongue:

      Thanks again for your help!

  • Nithin

    Hi Urbano,

    I hope you don't mind me chiming in, the above code will hide all the admin notices, so it's pretty tough to only allow some ID's. You could make use of a plugin like Adminimize, which allows us to hide certain elements, and portions of the dashboard according to user roles.

    Once you activate the plugin, under Settings > Adminimize > Global Options, add your own options to it, as shown in the screenshot below:

    Once you add you option name, and CSS class click Update Options to save it, once saved, you'll have to choose the role on which the you want the class to be deactivated, you'll have to repeat this process for all the notices which you want hidden.

    To determine a class name, or class ID, you'll have to right click on the element, and select Inspect element, and hover your mouse in order to view the class name.

    I hope this helps. Please let us know if you need any further assistance. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

  • Nithin

    Hi Urbano,

    Hope you are doing good today. :slight_smile:

    WP has a way to silent plugin warnings, but in this case you also needs some admin notices to be present for particular plugins. Using Adminimize would be the easiest option, as it would be much cleaner to use, and execute. As mentioned by Rupok, what the plugin does is pretty same, that is hiding the notices by CSS, since different plugins use different IDs, it's tough to give exact code according to each, with this plugin you only have to figure out the CSS class, or ID of each notices, and the plugin will hide the notices according.

    Please let us know if you still need any further help. We would be happy to troubleshoot it further. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.