WordPress

Disabling WordPress Theme File Editor

If you want to close the WordPress theme file editor section or want only the selected user to see it, you can use the WordPress editor close code below.

There is a useful editor in your WordPress admin panel that allows you to edit your themes and plugins.

Disabling WordPress Theme File Editor

If you want to close the WordPress theme file editor completely, follow the steps below.

  • Open your theme’s functions.php file. (/public_html/wp-content/themes/YOUR THEME/functions.php)
  • Add the following code to a suitable place. (You can add it before the ?> code at the bottom line.)
define('DISALLOW_FILE_EDIT', true); //Disables file editing using WP Editor.

Disable WordPress File Editor for Specific User

If you want the WordPress editor to be visible only to the user you selected and hidden for all other users, follow the steps below.

  • Open your theme’s functions.php file. (/public_html/wp-content/themes/YOUR THEME/functions.php)
  • Add the following code to a suitable place. (You can add it before the ?> code at the bottom line.)
  • if($current_user->user_login == ‘admin’) { //Add your username => Write your own username here instead of admin.
  • No one else will be able to use or see the editor except the user you added.
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') { //Add username
add_action('admin_menu', 'wpr_remove_editor_menu', 1);
}

Leave a Comment

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

Scroll to Top