Friday, 7 October 2011

How to disable wordpress theme change?

If we are developing any website, we will try different layouts to check which one is suitable for the website. Like this I tried many themes for one of my client website and finalized one layout among all of them and customized it according to my client requirements.

At the time of theme customization we will place the widgets at different locations where have the chance to place the widgets like sidebar and footer and header.

If we switch from the current theme to any another theme and come back, then the widgets which we placed in our current theme will be lost and again we have to place the widgets.

I faced this problem for one of my client website and then I decided to restrict switch the theme.

For that I added the following code and it works well for me and solved my problem

add_action('admin_init', lock_theme');
function  lock_theme() {
            global $submenu, $userdata;
            if ($userdata->ID != 1) {

Hope this will be useful.

No comments:

Post a Comment