WordPress – Hide Theme Options from other admin

I am working on a template and I am currently trying to find a solution or method to effectively hide the THEME OPTIONS located in APPEARANCE from another admin user?

I would not like to strip my co-admin from his “admin privileges” and change him to a lower class however I am seeking a possibility to hide this element from him so that he can’t change the main theme options/settings.

Read More

Some help would be greatly appreciated.

Thank you very much,
Patrick

Related posts

Leave a Reply

1 comment

  1. You could use the built in WordPress function remove_submenu_page in a function which checked for a specific user ID. You would hook that to admin_head.

    <?php
    
    function hide_menu() {
     global $current_user;
     $user_id = get_current_user_id();
     // echo "user:".$user_id;   // Use this to find your user id quickly
    
        if($user_id != '1') {
    
            // To remove the whole Appearance admin menu you would use;
            remove_menu_page( 'themes.php' );
    
            // To remove the theme editor and theme options submenus from
            // the Appearance admin menu, as well as the main 'Themes'
            // submenu you would use 
    
            remove_submenu_page( 'themes.php', 'themes.php' );
            remove_submenu_page( 'themes.php', 'theme-editor.php' );
            remove_submenu_page( 'themes.php', 'theme_options' );
    
        }
    }
    
    add_action('admin_head', 'hide_menu');
    ?>
    

    However, it should be noted (as per the comments) that using this only hides the menu item it doesn’t completely disable it and it could be accessed directly from the browser. If you really have to keep this other person as an administrator rather than a user with lower privileges, and you have to make sure they cannot access the theme options at all then you should think about using a plugin to create a new user access level with custom capabilities (I say use a plugin as I don’t believe there’s any point in coding that up yourself, you are just reinventing the wheel).