Paulund
2012-09-10 #wordpress

Disable Changing The Wordpress Theme

The problem with having a multi-author blog is that you have a lot of users which have access to the admin area of your Wordpress site. When they have access to your admin site they have access to change everything about your blog. Yes you can use your access roles and set the different capabilities, but what if you have multiple admin users but you only want the super admin user to be admin to change theme or plugins. You need a way of blocking access to the themes area. You can block access to the themes screen to anyone apart from the super admin user. Below is the snippet to check the user ID and remove the themes item from the menu.


/**
* Disable changing the theme for anyone a part from the admin user
*/
add_action('admin_init', 'disable_changing_theme_for_non_admin');

function disable_changing_theme_for_non_admin() {
    global $submenu, $userdata;
    get_currentuserinfo();
    if ($userdata->ID != 1) {
        unset($submenu['themes.php'][5]);
    }
}