Post Pic

How to easily disable theme changing

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!

One Response

Jul 19 2011 19:28

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]);
}
}

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required

WP Theme of the week

Sponsored Likebox