Looking for help with some admin customizations.

I have been building out a WordPress install for a hosting client. For the most part I will be managing their website, but they want the ability to upload and install themes and plugins themselves.

I have the install just about ready for them, but have 4 items that I haven't been able to come up with a solution for. If anyone can help it would be greatly appreciated.

1. I want to hide the WP Admin bar on the front side of the website when the client is logged in. I know this option can be set in the user profile, but I'd like to do it on a global basis so it would be hidden for any users add automatically. Currently I'm using a plugin called Global Hide Toolbar which is working but I'm thinking this can be done through code (maybe in the functions.php file) rather than having to use a plugin.

2. I'm using a few plugins to manage the website that I don't want to show on the Installed Plugins page. I'm using a combination of User Role Editor and Admin Menu Editor Pro to create a new user role and hide/restrict access to certain things, but there doesn't see to be a way to "hide" plugins from the listing. Again, maybe this is something that could be added to the functions.php?

3. On the Post and Page editor pages, you can display the "Author" box which has a drop down menu to select the Author you want the Post or Page to be published by. I would like to remove the standard "Administrator" role from this selection. So myself, or anyone with a full Admin roll, won't show in the drop down. My client is using a modified Editor role that was created using the URE plugin, so if there was a way to just hide any user with the Admin role, that would be perfect.

4. Lastly, I want to limit the file size that can be uploaded through the Media Library. Right now my host allows a 50MB file to be uploaded. Changing the php.ini file to be 2MB would be possible, but it would also decrease the upload size for themes and plugins. I want to make sure they don't have limitations on those uploads.

BTW, I asked this last question as a separate post yesterday, just thought I'd include it again just in case anyone else had an idea.

Thanks again in advance for any help,

  • Jude

    Howdy @Trevor

    Thanks for getting in touch !

    1) You can use this snippet to hide the admin bar globally from functions.php

    add_filter('show_admin_bar', '__return_false');

    2) You need to edit plugin names and paste it in your functions.php file

    add_filter( 'all_plugins', 'hide_plugins');
    function hide_plugins($plugins)
    	// Hide Hello dolly plugin
    	if(is_plugin_active('hello.php')) {
    		unset( $plugins['hello.php'] );
    	// Hide disqus plugin
    	if(is_plugin_active('disqus-comment-system/disqus.php')) {
    		unset( $plugins['disqus-comment-system/disqus.php'] );
    	return $plugins;

    3) This may not be possible without hacking at the core. What you can do is hide the author meta box for specific roles, as shown below.

    function my_remove_meta_boxes()
            if (! current_user_can('editor') ) :
    		remove_meta_box('authordiv', 'post', 'normal');
    		remove_meta_box('authordiv', 'page', 'normal');
    	add_action( 'do_meta_boxes', 'remove_meta_boxes' );

    4) You can try the wp-config or the functions.php methods as described here. That way the PHP handler still has a larger limit.


    Hope that helps


  • Trevor

    Hi, thanks for your input above. I'm still working through these, but number 1 worked perfectly.

    On number 2, the code itself worked great and hid the plugins that I specified. The issue is it hid the plugins globally, for all user roles. Is there a way to hide those plugins for every role except the Administrator? As the Admin I want to be able to see them and receive notifications of plugin updates.

    Thanks again,

  • Trevor

    I've created a site specific plugin that acts like a functions.php file but is not inside of a theme, so it remains independent of any updates.

    I've used the Imsanity plugin before and it does a good job. The issue is the server still needs to initially store the large files and then process the files to a smaller size, thus using system resources. I would like to avoid the additional load up front and just have the client use an optimized file. I may install WP Smush Pro to then optimize the files even more on the backend but a least the source files will be smaller.

  • joe

    Good thinking Trevor, I never thought of Smush Pro. I must admit I am fortunate that I have quite extensive server resources so I rarely suffer performance issues, but that's what you call tempting fate as it will probably go belly up now I've said it.

    I have used that little snippet previously to hide the admin bar

    add_filter('show_admin_bar', '__return_false');

    But what I didn't like was it removed the "How are you" text that sort of reminded users they were actually logged in. Probably an easy fix, but I never quite got round to it.

  • Trevor

    I wanted to share my findings.

    So I did a little digging on question number 2 above. Jude's answer pointed me in the right direction as the code suggested worked, but removed the plugins listed for ALL users. As the site admin, I want to be able to see all the plugins but the client doesn't need to. I found the below code and tweaked it for my needs:

    add_filter( 'all_plugins', 'plugin_permissions_so_3707134' );

    * Filter the list of plugins according to user_login
    * Usage: configure the variable $plugin_credentials, which holds a list of users and their plugins.
    * To give full access, put a simple string "ALL"
    * To grant only for some plugins, create an array with the Plugin Slug,
    * which is the file name without extension (akismet.php, hello.php)
    * @return array List of plugins
    function plugin_permissions_so_3707134( $plugins )
    // plugins restricted
    $plugin_restrict = array('name-of-plugin','name-of-plugin','name-of-plugin',);

    //usernames of each admin allowed access
    $allowed_users = array('AdminUsername');

    // Current user
    global $current_user;
    $username = $current_user->user_login;

    // Super admin, return everything
    if (in_array($username, $allowed_users)) return $plugins;

    // Filter the plugins of the user
    foreach ( $plugins as $key => $value )
    // Get the file name minus extension
    $plugin_slug = basename( $key, '.php' );

    // If not in the list of allowed plugins, remove from array
    if( in_array( $plugin_slug, $plugin_restrict ) )
    unset( $plugins[ $key ] );

    return $plugins;

    The end result, the Administrator can see all of the plugins, and any other user can only see the plugins not specified in the code to be hidden. Worked great!

    There is one little issue, if there is an update to a hidden plugin, an indication will display in the client's left navigation showing that a plugin needs to be updated. When the client clicks in to view the Installed Plugins, the listing will not show the hidden plugin requiring the update. That may be a little confusing to them.

    BTW, I created a site specific plugin and added the above code to that rather than adding it to the theme's functions.php file. This gives the client the ability to change themes without losing the code. Here's a link to learn more about creating a Site Specific plugin: http://www.wpbeginner.com/beginners-guide/what-why-and-how-tos-of-creating-a-site-specific-wordpress-plugin/

    I also added the code for removing the front side Admin Bar to this plugin as well.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.