Even a well-protected wp-admin area cannot guarantee site security if an administrator account is compromised. An attacker with the appropriate permissions may install a plugin containing malicious code and gain control over WordPress files.
For sites with a controlled deployment process, it is reasonable to prohibit the installation, updating, and removal of plugins and themes through the admin area. In this setup, changes go through staging, backups, testing, and SSH or CI/CD.
What DISALLOW_FILE_MODS Does
WordPress provides the DISALLOW_FILE_MODS constant, which disables file-modification operations performed through the administration area. Once enabled, users cannot install, update, or delete plugins and themes from wp-admin.
This also restricts component updates through WordPress's standard mechanisms. Therefore, automatic updates for the WordPress core, plugins, and themes should not be considered an available maintenance method; they must be moved to a controlled deployment process.
The setting does not remove components that are already installed and does not disable their execution. If the site already contains a vulnerable or infected plugin, the constant alone will not resolve the problem.
- prevents plugin and theme installation through the admin area;
- blocks plugin and theme updates and removal through WordPress;
- reduces the potential impact of a compromised administrator account;
- moves control over file changes to the server or deployment system.
How to Enable the Restriction in wp-config.php
Before editing the file, create a backup of wp-config.php or save its current contents. Add the constant to wp-config.php, usually before the line containing the comment that marks the end of WordPress configuration editing.
- Open wp-config.php through SSH, your hosting file manager, or another secure access channel.
- Add the constant only once so that the file does not contain conflicting definitions.
- Save the file and check that the PHP syntax has not been damaged.
- Sign in to wp-admin and check the plugin and theme management pages.
define('DISALLOW_FILE_MODS', true);
Where Exactly to Place the Constant
The constant must be defined before WordPress completes the configuration loading process. In practice, it is placed in wp-config.php near other security and database connection settings, but before the file's final system line.
Do not add the PHP tags a second time if they are already present in the file. Also, do not leave unnecessary characters or whitespace before the opening PHP tag if this could cause header errors.
- Do not duplicate define() statements in different parts of the configuration.
- Test changes on a staging copy first.
- After editing, check the homepage, wp-admin, and critical forms.
What Changes for the Administrator and Elementor
After enabling the setting, installation, update, and removal actions for plugins and themes may disappear from the administration area or become unavailable. This is expected behavior, not a sign that WordPress is malfunctioning.
Elementor and other page builders will continue to work for page editing if the plugin is already installed and compatible with the current WordPress version. However, updates to Elementor, its integrations, the theme, or additional extensions will have to be performed outside the admin area.
Disabling file modifications is not the same as disabling content editing. Users can still change pages, posts, menus, or settings if their roles allow it. To separately block the built-in file editor, use the DISALLOW_FILE_EDIT constant.
- Elementor page editing should not be blocked solely by DISALLOW_FILE_MODS.
- Templates, widgets, and content can still be changed according to the user's permissions.
- Plan Elementor updates in the same way as updates for any other plugin.
How to Organize Updates Without wp-admin
Disabling component installation only makes sense when a clear update process exists. Otherwise, the site will gradually accumulate outdated versions and vulnerabilities.
A secure process usually starts with a staging environment. On a copy of the site, test the compatibility of WordPress, the theme, Elementor, plugins, PHP, and integrations. Then create a backup of the production site, perform the update through SSH, WP-CLI, or CI/CD, and verify the result.
- Keep a list of installed plugins, themes, and their versions.
- Update components on staging first.
- Before deployment, verify the backup and the ability to roll back.
- After updating, test authentication, forms, payments, search, caching, and key pages.
- Do not leave staging accessible to outside users without access protection.
Important Limitations to Consider
DISALLOW_FILE_MODS is not a complete WordPress security system. It controls changes performed through standard WordPress mechanisms, but it does not replace protection for hosting, accounts, or the file system.
A user who gains SSH access, access to the hosting control panel, or the ability to execute commands on the server may potentially modify files regardless of this setting. Likewise, the constant does not prevent the exploitation of a vulnerability in an already installed plugin.
Also check file and directory permissions, SSH security, multi-factor authentication, backups, event logs, and access to the hosting control panel. Configuration files must not be accessible through the web server.
- Do not rely solely on hiding the wp-admin URL.
- Remove unused plugins and themes instead of merely leaving them deactivated.
- Grant administrative privileges only to people who genuinely need them.
- Store backups separately from the production server.
- Review login logs and records of unplanned file changes.
Post-Configuration Checks and Common Mistakes
After making the change, verify the result using an account with the required administrative permissions. An attempt to install or update a plugin should end with a message indicating that file modifications are restricted. If the actions remain available, check whether you edited the wp-config.php file actually used by the site.
A common mistake is adding the constant after the configuration's final system line or defining its value as false in another file. Another problem occurs when a site owner enables the restriction without preparing an update process and consequently delays fixes for critical vulnerabilities.
- Check the path to the active WordPress installation.
- Make sure the constant's value is true.
- Check the PHP error log after changing the configuration.
- Perform a test update on staging rather than directly on the live site.
- Document the rollback procedure and assign responsibility for updates.
Frequently asked questions
Will plugins still be updateable after DISALLOW_FILE_MODS is enabled?
Yes, but not through the standard WordPress admin area. Updates must be performed through a controlled channel, such as staging followed by deployment, SSH, WP-CLI, or CI/CD, depending on the site's infrastructure.
Will this constant block editing pages in Elementor?
No. The constant itself should not block content editing in Elementor. It restricts file operations involving plugins and themes, but not page changes made by users with the appropriate permissions.
Does DISALLOW_FILE_MODS protect against an infected plugin?
It reduces the risk of installing a new malicious plugin through the admin area, but it does not remove already infected files or protect against vulnerabilities in installed components.
What should I do if I urgently need to install a plugin?
First test the plugin on staging, create a backup, and install it through an approved deployment channel. Temporarily disabling the protection without controls, logging, and subsequent verification creates unnecessary risk.
Conclusion
DISALLOW_FILE_MODS is a practical hardening measure for WordPress sites with controlled deployments. It prevents a compromised administrator from quickly installing or replacing a plugin through wp-admin.
For this restriction to genuinely improve security, combine it with regular updates, staging, backups, least-privilege access, and server protection. A locked-down admin area must not turn into a site running outdated components.