Short answer: To disable file editing in WordPress, add define( 'DISALLOW_FILE_EDIT', true ); to wp-config.php above the line that says to stop editing. That removes the theme file editor and plugin file editor from the dashboard, so a stolen admin account cannot paste malicious PHP into your theme or plugins from a browser. If you also want to block installing, updating and deleting plugins and themes from the admin area, use DISALLOW_FILE_MODS instead, which includes the editor block. Be careful with the second option: it also stops dashboard updates, so only use it if you deploy updates another way. Neither constant stops changes made over SFTP or SSH.
Why the built-in editors are a risk
WordPress ships with two editors under Appearance and Plugins that let an administrator change PHP files directly from the dashboard. They are convenient for quick tweaks, but they turn any admin login into a code execution tool. If an attacker phishes an administrator’s password, abuses a plugin bug that creates an admin account, or hijacks a logged-in session, the editors let them add a backdoor in seconds without needing any server access.

It is a familiar pattern in hacked-site clean-ups: a rogue admin account appears, and shortly afterwards a few unfamiliar lines show up in a theme or plugin file. Disabling the editor does not stop the account from being created, but it removes the easiest next step. WordPress’s own wp-config documentation describes the constant as a way to prevent overzealous users from editing sensitive files, and it is one of the cheapest controls you can add.
DISALLOW_FILE_EDIT vs DISALLOW_FILE_MODS
| Effect in the admin area | DISALLOW_FILE_EDIT | DISALLOW_FILE_MODS |
|---|---|---|
| Theme and plugin file editors | Disabled | Disabled |
| Install, update or delete plugins | Still allowed | Blocked |
| Install, update or delete themes | Still allowed | Blocked |
| Core updates from Dashboard, Updates | Still allowed | Blocked |
| Changes over SFTP, SSH or deployment | Still possible | Still possible |
WordPress’s own documentation confirms that DISALLOW_FILE_MODS blocks plugin and theme installation and update from the admin area and also disables the file editors, so you do not need both constants. In current WordPress core the background automatic updater also checks whether file modifications are allowed, so DISALLOW_FILE_MODS effectively stops automatic updates too. That is a serious trade-off on a site that relies on auto-updates for security patches.
Which one should you use?
Most site owners should use DISALLOW_FILE_EDIT. It removes the dangerous editor while keeping one-click updates, which matter more for security than almost anything else. Use DISALLOW_FILE_MODS only if you manage updates through a deployment pipeline, WP-CLI on the server or a host that handles them, and you want the dashboard to be read-only for code. Agencies running many client sites sometimes choose it so clients cannot install random plugins.
How to add the constant
- Back up wp-config.php before editing it.
- Open wp-config.php in the WordPress root directory using SFTP, your host’s file manager or SSH.
- Find the line that reads
/* That's all, stop editing! Happy publishing. */. - Add the constant on its own line above it.
- Save the file and reload the dashboard.
define( 'DISALLOW_FILE_EDIT', true );
Or, for the stricter option:
define( 'DISALLOW_FILE_MODS', true );
If you use WP-CLI, you can set it without opening the file:
wp config set DISALLOW_FILE_EDIT true --raw
wp config get DISALLOW_FILE_EDIT
The --raw flag writes the value as a boolean rather than the string true. Our guide to wp-config.php hardening covers file permissions and other constants worth setting while you are in the file.
How to test that it worked
Log in as an administrator. The Theme File Editor under Appearance and the Plugin File Editor under Plugins should be gone from the menus. Visiting the editor screens directly should return a permissions message instead of the editor. If you chose DISALLOW_FILE_MODS, the Add New button for plugins and themes should disappear and update links should no longer appear.
If the editors are still visible, check for a duplicate definition later in wp-config.php that sets the value to false, a typo in the constant name, or a hosting setup that loads a different config file. Constants can only be defined once, so the first definition wins.

Things that can break
WordPress documentation notes that disabling the editor can affect plugins that check the edit_plugins capability. Plugin authors are told to avoid relying on that check, but some still do. If a plugin feature stops working after the change, that may be the cause; contact the plugin developer rather than re-enabling the editor.
With DISALLOW_FILE_MODS, the bigger risk is forgetting it is there. Months later someone wonders why the site has not updated. Leave a comment in your own documentation, set a reminder to update manually, and monitor for outdated plugins.
What this does not protect against
These constants are about the dashboard. An attacker with SFTP credentials, a vulnerable plugin that allows file upload, or write access through weak file permissions can still change files. That is why disabling the editor works best alongside correct permissions, least-privilege admin accounts and file change monitoring. See our explainer on WordPress file permissions for recommended values, and our list of places attackers hide WordPress backdoors for what to check if you suspect the editor was already abused.
Also remember that an attacker with admin access could install a malicious plugin if DISALLOW_FILE_EDIT is set but file modifications are allowed. Strong passwords, two-factor authentication for every administrator and a short list of admin users close that gap.
A quick audit after enabling it
Turning off the editor is a good moment to check whether it was ever misused. Compare core files against official checksums with wp core verify-checksums, and plugins with wp plugin verify-checksums --all, both of which report files that differ from the published versions. Themes are not covered by checksum tools, so look at the modified dates of files in your active theme and compare them with the dates you actually made changes. A functions.php modified on a day nobody touched the site deserves a closer look.
Then review who can log in as an administrator. Every admin account is a potential path to code, even with the editor disabled, because admins can still install plugins unless file modifications are blocked. Remove accounts that belong to former staff or agencies, and require two-factor authentication for the rest.
Frequently asked questions
Do I need both DISALLOW_FILE_EDIT and DISALLOW_FILE_MODS?
No. WordPress documentation says DISALLOW_FILE_MODS also disables the file editors, so setting it alone covers both.
Will DISALLOW_FILE_EDIT stop plugin updates?
No. It only removes the file editors. Plugin, theme and core updates continue to work from the dashboard.
Can a security plugin do this instead?
Many security plugins offer a toggle that adds the same constant. Setting it yourself in wp-config.php works even if the plugin is deactivated.
How do I edit theme files after disabling the editor?
Use SFTP or SSH with a proper code editor, ideally working on a staging copy and keeping changes in a child theme or version control.



