WordPress GuidePlugins → Disable Plugin Deactivation

How to disable plugin deactivation in WordPress

Sometimes, the wrong person clicks the wrong button—and suddenly, your most important WordPress plugin is deactivated. If you run a multi-user site or manage a project with clients, preventing plugin deactivation can save your site from serious functionality issues.

Let’s look at how to disable plugin deactivation in WordPress, step-by-step.

Get fast, reliable hosting for WordPress

Power your site with the industry’s fastest, most optimized WordPress hosting

Why you might want to disable plugin deactivation

Preventing users from deactivating plugins is about control and stability. Whether you’re protecting security tools, ecommerce systems, or core functionality plugins, it’s a smart way to:

WordPress doesn’t offer a built-in toggle for this, but you can disable plugin deactivation using code or role restrictions.

Method 1: Use DISALLOW_FILE_MODS in wp-config.php

If you want to prevent any file modifications—including plugin installations, updates, and deactivations—the most secure way is with DISALLOW_FILE_MODS.

Steps:

This disables the plugin and theme editors, plugin installations, updates, and deactivation. It’s an aggressive option that works best when you don’t want users managing plugins at all.

Important: Admins won’t be able to install or update plugins from the dashboard either. For most production sites, this is a feature—not a bug.

Method 2: Disable the plugin editor only (DISALLOW_FILE_EDIT)

If you just want to block users from editing plugin and theme files (but still allow deactivation), use:

define(‘DISALLOW_FILE_EDIT’, true);

Place it in wp-config.php the same way as above. This doesn’t block plugin deactivation, but it’s useful to combine with other methods for extra safety.

To fully prevent plugin deactivation, combine this with user role controls or a dedicated plugin.

Method 3: Restrict plugin access by user role

For more control over who can manage plugins, modify user capabilities. WordPress assigns the ability to activate and deactivate plugins via the activate_plugins capability.

Option A: Use a role editor plugin

Install a plugin like User Role Editor:

Now, users with that role won’t see plugin management options in the dashboard.

Option B: Add custom code to functions.php or a plugin

If you prefer code, you can strip capabilities from roles with:

This example targets the Editor role. You can copy the function and modify it for other roles as needed.

Note: Admin users still retain full plugin access unless you remove those capabilities from the administrator role—which isn’t recommended unless you’re running a multisite or very locked-down setup.

Method 4: Use a security plugin to block deactivation or access

Several popular WordPress security plugins offer features that restrict plugin access or harden your site against unauthorized changes.

Look for plugins like Solid Security. These typically include toggles to:

Check the plugin’s settings for file change or plugin management protections. This is a non-technical way to add the same security that code provides.

What to know before locking plugin deactivation

Additional resources

What is a WordPress plugin? →

A complete beginner’s guide to WordPress plugins and how to manage them

School Management System for WordPress: Top 7 [Updated]→

Manage classes, students, staff, and academic activities efficiently with a school management plugin for WordPress.









How to check if a plugin is safe →

Simple steps to evaluating a plugin before you install and activate it