Dashboard security

How to disable WordPress file editing

Disabling WordPress file editing removes the built-in theme and plugin code editors from the dashboard. You can still edit pages, use Elementor and manage normal content. The change reduces accidental code edits and removes one route for modifying files through an administrator account.

Time: 10-20 minutes Level: Intermediate
Neil McNaught, founder of BugShield and WordPress author
Written by
Written by
Updated
Updated

Prepare hosting access before changing the setting

You apply this restriction in a configuration file outside the WordPress dashboard. Check that you can open your hosting File Manager and keep a private recovery copy before editing. Those preparations give you a way to correct a typing error even if the website stops loading after you save.

Understand which editors this affects

The Theme File Editor and Plugin File Editor change the PHP, CSS and other source files that run your site. A mistake there can break public pages. They are different from the block-based Site Editor, the page editor and Elementor's visual editor.

This setting does not stop file changes through hosting tools or prevent a compromised administrator from using every other administrative feature. Combine it with appropriate user roles and two-factor authentication. It is one restriction, not proof that the site is secure.

1. Check whether the file editors are already disabled

Sign in as an administrator. Look for Theme File Editor and Plugin File Editor. Their menu locations depend on the theme and WordPress version; check Appearance, Plugins and Tools. An Editor-role user cannot use these administration tools by default, so test with the correct account.

If neither is present, your host or security plugin can already be enforcing this restriction. Check its settings or ask the host before changing configuration. Do not disable an existing security feature just to make the menus appear for this test.

WordPress Theme File Editor displaying the Twenty Nineteen stylesheet and an Update File button
This older WordPress example shows the code editor being restricted, with a file list and Update File button. It is different from Elementor or the page editor. Do not change the displayed code as part of this check. Credit: WordPress Documentation Team, CC0.

2. Find and save wp-config.php

Sign in to the hosting account, select the correct website and open File Manager. Find the folder containing wp-admin and wp-content, then locate wp-config.php. Some installations keep it one directory above; ask the host if its location is unclear.

Download an untouched copy to a private folder on your computer before editing. The file contains credentials, so do not leave a renamed backup such as wp-config.php.bak in the public website directory. Keep the hosting session open until verification is complete; it is your recovery route if WordPress stops loading.

3. Add or update the single setting

Use File Manager's text editor to open the file and search for DISALLOW_FILE_EDIT. If it already exists with true, leave it alone. If it has false, change that existing value to true. Do not create a second definition.

If no definition exists, add the following line above the stop-editing comment and before the statement that loads wp-settings.php. Keep the spelling, straight quotes and final semicolon exactly as shown. Add no extra opening or closing PHP tags.

php
define( 'DISALLOW_FILE_EDIT', true );

4. Save and verify both administration and content editing

Save the file and reload the public homepage. Open a fresh dashboard page with your administrator account and confirm the two file-editor menus are gone. For a direct access check, append /wp-admin/theme-editor.php and /wp-admin/plugin-editor.php to your site address; WordPress should refuse access to those code editors.

Open a draft page and confirm its normal editor still works. If you use Elementor, open the draft there too. Review Dashboard > Updates to check that your usual update workflow remains available, without installing an update merely for this test.

If saving caused a syntax error or blank page, restore the untouched wp-config.php copy through File Manager. Do not repeatedly edit a broken live file by trial and error. The syntax-error guide explains how to identify a damaged file if the error persists.

5. Keep a record of the restriction

Note that the setting is in the site's configuration file so a future maintainer understands why the menus are unavailable. If you deliberately need to undo your own change, remove only the line you added or restore its previous value, then check access again. Arrange code changes through a tested file workflow rather than switching the dashboard editors on for everyday content work.

Official reference

WordPress documents the file-editor restriction and the separate file-modification setting.

Get help with the next step

If you are unsure which configuration file belongs to the site, ask BugShield for help with administration settings. We can help check the restriction without making unrelated changes to the editing workflow.

Questions answered

How to disable WordPress file editing FAQs

Will this stop me using Elementor?

The setting disables WordPress's built-in plugin and theme source-code editors. It does not intentionally disable Elementor or normal page editing; verify your draft page after the change.

Does this block plugin updates?

DISALLOW_FILE_EDIT does not itself block normal plugin updates. The different DISALLOW_FILE_MODS setting blocks installation and update operations too.

Why are the file editors already missing?

The account role, hosting configuration or a security plugin can restrict them. Check those controls with an administrator account before adding another setting.

Can somebody still change files through hosting?

Yes. This controls the built-in WordPress editors, not hosting File Manager or secure file-transfer access. Protect those accounts separately.

What should I do if the site breaks after saving?

Use the open hosting File Manager session to replace wp-config.php with the untouched private copy. Check the site loads before investigating the failed edit.

Need a hand with your WordPress site?

Tell us what happened and where you got stuck. A BugShield developer can help you work out the next step and confirm a price for the fix.

Explore help with this issue

Accessibility settings

Adjust how this site looks and moves. Your choices are saved in this browser.