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

If you’re a freelancer who often install WordPress on your clients websites, chances are that you don’t want them to be able to edit their theme. Here is a simple code snippet to hide the Theme Editor link from the dashboard so you can be sure that your clients won’t destroy their theme.

Simply paste the following code on the theme functions.php file. Specify the admin username on line 7 so the admin will still see the theme editor link.

function wpr_remove_editor_menu() {
  remove_action('admin_menu', '_add_themes_utility_last', 101);
}

global $remove_submenu_page, $current_user;
get_currentuserinfo();
if($current_user->user_login == 'admin') { //Specify admin name here
    add_action('admin_menu', 'wpr_remove_editor_menu', 1);
} 

7 Comments

  1. Or, you could just use this line of code in your wp-config.php file:

    define('DISALLOW_FILE_EDIT', TRUE);

  2. Another option would be to define it in the wp-config.php file, this would be a better solution as its site wide regardless if the theme is changed :-)
    define( ‘DISALLOW_FILE_EDIT’, true);

  3. You beat me to it Nathan :-)

  4. I like that solution better than the wp-config one, because it will allows to retain the editor for one particular admin.
    You can get that modification as automatized as with wp-config in putting it in a plugin in the “magic” mu-plugins directory.

  5. Obviously not as clean to do this, but for those who aren’t comfortable getting into the code there are plenty of plugins that can allow you to do this. White Label CMS is the main one that springs to mind but there are plenty of premium ones flying around on CodeCanyon and elsewhere.

    (Note: If you are creating a WordPress site for a client you almost definitely should be comfortable with the code.)

  6. What is the free wp plugin can do the jobe, James?

  7. Thx for this useful feature. That will block the final user/client to messaround with the basic theme files… great :)

Leave a Comment

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