DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

When creating a WordPress based website for a client, you may need to make sure that he can’t switch themes. This is what I’m going to show you in today’s recipe.

Simply paste the following piece of code in your functions.php file:

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

Once saved, your client will not be able to switch themes anymore.

Thanks to Steve Taylor for this cool recipe!

Tags

One Comment

  1. Nice tip. You could modify this for multiple admins as such:

    add_action(‘admin_init’, ‘slt_lock_theme’);

    function slt_lock_theme() {
    if ( !current_user_can( ‘manage_options’ )) {
    unset($submenu[‘themes.php’][5]);
    unset($submenu[‘themes.php’][15]);
    }
    }

Leave a Comment

Your email address will not be published. Required fields are marked *