Can you hide sections of the admin like "appearance" ,

Can you hide sections of the admin like "appearance" , "settings", etc. for a network?

I am looking under ultimate branding, but can't seem to find the ability to keep that private.

I don't want my network sub-sites to show any theme, plugin, settings, etc.

Is that possible?

  • Vinod Dalvi

    Hi Sam,

    I hope you are well today and thank you for your question.

    You can achieve this by downloading and using the attached small plugin by network activating it which contains the following code.

    <?php
    /*
    Plugin Name: Quick Custom Solution Plugin
    Plugin URI: https://premium.wpmudev.org
    Description: Quick Custom Solution Plugin for Implementing Custom Solution.
    Version: 1.0.0
    Author: Vinod Dalvi (Incsub)
    Author URI: https://premium.wpmudev.org/
    License: GNU General Public License (Version 2 - GPLv2)
    */
    
    /* --------------------------------------------------------------------
    Remove Unwanted Menu Items from the WordPress Dashboard
    - Requires WordPress 3.1+
    -------------------------------------------------------------------- */
    function custom_remove_admin_menus (){
    
      // Check that the built-in WordPress function remove_menu_page() exists in the current installation
      if ( function_exists('remove_menu_page') ) { 
    
        /* Remove unwanted menu items by passing their slug to the remove_menu_item() function.
        You can comment out the items you want to keep. */
    
        // remove_menu_page('index.php'); // Dashboard tab
        // remove_menu_page('edit.php'); // Posts
        // remove_menu_page('edit.php?post_type=page'); // Pages
        // remove_menu_page('upload.php'); // Media
        // remove_menu_page('link-manager.php'); // Links
        // remove_menu_page('edit-comments.php'); // Comments
        remove_menu_page('themes.php'); // Appearance
        remove_menu_page('plugins.php'); // Plugins
        // remove_menu_page('users.php'); // Users
        // remove_menu_page('tools.php'); // Tools
        remove_menu_page('options-general.php'); // Settings
    
      }
    
    }
    // Add our function to the admin_menu action
    add_action('admin_menu', 'custom_remove_admin_menus'); 
    
    ?>

    Alternatively you can also consider using the following plugin to achieve it.

    https://wordpress.org/plugins/admin-menu-editor/

    Best Regards,
    Vinod Dalvi

  • Sam

    I used the simple file, and it works for the most part. I called my plugins - extensions, so the plugins are showing up. But I am using pretty plugins, so changing the name may be why.

    One more quick question, if I decide to use the the (Admin Menu Editor Plugin) instead . . . will it hide the menu areas from all sub-site admins too?

    Also, what happens if a sub-sites chooses to use domain mapping? Will it still work? Or would I need to do something else.

    Sam

  • Sam

    Also, If I decide to keep the simple file, I can just hide any extra areas by adding new lines to the code right?

    Real quick, how come some lines have // at the beginning, and some don't. If you look at this clip here. Appearance, Plugins, and Settings don't have double slash at the beginning. But the others do. Refresh my memory, are they not necessary?

    remove_menu_page('themes.php'); // Appearance
    remove_menu_page('plugins.php'); // Plugins
    // remove_menu_page('users.php'); // Users
    // remove_menu_page('tools.php'); // Tools
    remove_menu_page('options-general.php'); // Settings

  • Vinod Dalvi

    Hi Sam,

    Also, If I decide to keep the simple file, I can just hide any extra areas by adding new lines to the code right?

    Right i have added more options for your convenience which is disabled for now by commenting it but you can uncomment it to use it.

    Real quick, how come some lines have // at the beginning, and some don't. If you look at this clip here. Appearance, Plugins, and Settings don't have double slash at the beginning. But the others do. Refresh my memory, are they not necessary?

    It's // the PHP comments. Find more information about it on the following pages.

    http://www.w3schools.com/php/php_syntax.asp
    http://php.net/manual/en/language.basic-syntax.comments.php

    Adding these lines before any PHP statements means commenting/disabling it and removing it meand uncommenting/activating the statements.

    I have commented all the PHP statements except few because currently you want to only hide the admin menus like "appearance" , "themes", "plugins", "settings" etc.

    if you find this hard to use then i suggest you to use the plugin to achieve it as suggested in my previous reply. Feel free to ask us if you face any issue with it.

    Thanks,
    Vinod Dalvi

  • Sam

    Hi Vinod,

    I tried that other plugin, and it is managed at the site level, and not the Network Level. So that won't work for me.

    So I am going back to using the simple plugin that you built.

    My assumption to why it wasn't working is that I am using "pretty plugins" extension, and I changed the term from 'plugins' to 'extensions'. So the code needs to be changed to reflect that in the simple plugin. Right?

    Also, is there a way to hide like "appearance" but let users still access "theme settings" which is a sub-menu of "appearance". That may not make sense. But I want to give users the ability to change their logo, theme settings, etc. Just not switch themes without Admin approval.

    Does that make sense? I guess my question is, what code could I add to this, to hide "sub-menus" off the main sections?

    Thanks in advance.

    Sam

  • Sam

    Hi Vinod,

    I thought I'd post this again, since I haven't heard back (concerning the thread above)

    Also, is there a way to hide like "appearance" but let users still access "theme settings" which is a sub-menu of "appearance". That may not make sense. But I want to give users the ability to change their logo, theme settings, etc. Just not switch themes without Admin approval.

    Does that make sense? I guess my question is, what code could I add to this, to hide "sub-menus" off the main sections?

    Thanks in advance.

    Sam

  • Vinod Dalvi

    Hi Sam,

    Also, is there a way to hide like "appearance" but let users still access "theme settings" which is a sub-menu of "appearance".

    No this is not possible as if you remove the parent menu then all its child menus also got removed automatically.

    In this case what you can do is to add the theme options as a parent menu in the admin menu and not as a child menu.

    Alternatively you can hide all the sub menus of Appearance menu as following except the Theme options and Themes menus.

    function custom_remove_admin_menus (){
    
      // Check that the built-in WordPress function remove_menu_page() exists in the current installation
      if ( function_exists('remove_menu_page') ) {
    // remove_menu_page('themes.php'); // Appearance
    remove_submenu_page('themes.php', 'widgets.php');
    remove_submenu_page('themes.php', 'nav-menus.php');
    global $submenu;
    // Appearance customize Menu
    unset($submenu['themes.php'][6]);
     }
    }
    // Add our function to the admin_menu action
    add_action('admin_menu', 'custom_remove_admin_menus', 999);
    ?>

    Remove the any extra sub menus of Appearance menu the same way as displayed above.

    Thanks,
    Vinod Dalvi

  • Sam

    Hi Vinod,

    Thanks for the response.

    One more question. Is it possible to block the menus, but allow the "super admin" to see them?
    So essentially, the individual site admins would be blocked. But the super admins would not.

    I didn't know if a line of code could be added to the original file to grant access to super admins only?

    Maybe not, but wanted to ask.

    I can use the new one if not.

    Thanks,

    Sam

  • Predrag Dubajic

    Hi Sam,

    My apologies for the delay on this thread.

    To make this work with super admin you will need to replace this line in your plugin:
    add_action('admin_menu', 'custom_remove_admin_menus');
    With this:

    add_action('init', 'remove_menus' );
    
    function remove_menus(){
        if ( !is_super_admin() ) {
            // Add our function to the admin_menu action
            add_action('admin_menu', 'custom_remove_admin_menus');
        }
    }

    Save the changes and that should be it.

    Let us know if this works for you.

    Best regards,
    Predrag

  • Sam

    Thanks Predrag,

    That worked fine.

    One more quick question. Is there any way to just hide the "themes" and their ability to change them out? Because I would like to grant access to widgets, and menus, which both fall under "appearance". So I thought about maybe hiding certain areas.

    Or is there some way I can distinguish between (themes.php), (widgets.php), and (nav-menus.php)

    In short, can I turn these certain areas on and off? Or are the themes, directly connected with (themes.php) and widgets and menus fall underneath?

    If nothing can be done. No big deal, but I thought I would ask.