Disable the Theme and Plugin Editor in WordPress

Disable the Theme and Plugin Editor in WordPress

Posted by Rainey

Sometimes I get that client that is just too curious for his or her own good.  This is great sometimes but when it comes to playing with the function.php page it can sometimes be a headache.  So, with a single line of code you can easily remove this functionality. You are technically supposed to add this to your wp-config file, but it works in the functions.php as well. (in cases where I want to limit it to a theme I made)

define('DISALLOW_FILE_EDIT', true);


There are a couple of other ways to do this, but these only remove the link and do not stop access to the editors:

function tcb_remove_editor_menu() {
  remove_action('admin_menu', '_add_themes_utility_last', 101);
add_action('admin_menu', 'tcb_remove_editor_menu', 1);


add_action('admin_init', 'tcb_remove_menu_elements', 102);
function tcb_remove_menu_elements(){
  remove_submenu_page( 'themes.php', 'theme-editor.php' );


That is it! Checkout TCBarret’s blog for more on this and the WordPress Codex for more info on editing the wp-config file.



Like what you are reading? Subscribe to receive monthly tips & updates!

A Monthly Roundup of Articles and a Sweet Deal

Get the latest tips, tricks, tutorials and freebies in your inbox once a monthly.

Join our growing community of front-end web developers and designers. We are constantly publishing new industry tips, tricks and tutorials to help you take your game to the next level. We are also going to include a freebie or deal on something cool each month. Enter your email below and you will only receive this email once a month, nothing else.

Subscribe to our mailing list

* indicates required

    Today in Web Design - Tutorials