Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Disable Plugin Deactivation from WordPress Admin Panel

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Disable Plugin Deactivation from WordPress Admin Panel

One of the best parts about WordPress is the availability of plugins that makes your job easy as a user and as a developer. Often when creating sites for clients, we as developers use plugins that are absolutely crucial for the site to have certain functionalities. Recently, we ran into a problem where one of our client’s site was broken. The sidebar wasn’t loading completely, there were missing elements on the single post page which freaked them out. The bottom line of this story was that one of their new staff members who was new to WordPress deactivated some of the plugins which were required for the site to function properly. We went in and activated all the plugins that were deactivated, but there had to be something done in order for us to prevent this issue in the future. In this article, we will show you how to disable plugin deactivation from WordPress Admin Panel (only for specific plugins).

Theoretically, you should be able to use Justin Tadlock’s Members plugin and create new role for users. However, the client we had did not want to go this route. It is a small business, and they hired this new employee to deal with their social media and blog, so we cannot restrict access. They wanted to give him the ability to activate/deactivate plugins at his will. We had to find a way which would keep our client happy, and we also had to find a way to prevent this issue from happening in the future. Thankfully to Steve Taylor, we found a snippet that lets you remove the “Deactivate” link from specified plugins. It also removes the Edit link for all plugins because we did not want our client to edit any plugins through the editor.

So all you have to do is paste the following codes in your theme’s functions.php file:

add_filter( 'plugin_action_links', 'disable_plugin_deactivation', 10, 4 );
function disable_plugin_deactivation( $actions, $plugin_file, $plugin_data, $context ) {
	// Remove edit link for all
	if ( array_key_exists( 'edit', $actions ) )
		unset( $actions['edit'] );
	// Remove deactivate link for crucial plugins
	if ( array_key_exists( 'deactivate', $actions ) && in_array( $plugin_file, array(
		unset( $actions['deactivate'] );
	return $actions;

Now, you need to change the array of $plugin_file where you see the list of specified plugins. The path of the file is relative to /wp-content/plugins/. So in the example above ‘facebook-open-graph-meta-in-wordpress/fbogmeta.php’ is a file located in the folder facebook-open-graph-meta-in-wordpress which is located inside the plugins folder. You can change the list to add as many plugins as you want.

This trick is a shortcut, and it does not actually prevent the actual deactivation. All we are doing is hiding the Deactivate link. Anyone with a little bit of WordPress knowledge can generate a deactivation URL and run it. But if your client is crafty enough to do that, then they already know what FTP is, and they can simply delete the plugins that way.

Are you working on a theme that absolutely requires a specific plugin for it to function properly? Then don’t forget to drop the code above.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. tc0nn says:

    This removed the deactivate link from all my plugins even though I intended to only remove it from one.

    • tconn says:

      This version seems to do what I wanted:

      add_filter( ‘plugin_action_links’, ‘disable_plugin_deactivation’, 10, 4 );
      function disable_plugin_deactivation($actions, $plugin_file, $plugin_data, $context){
      // Remove edit link for all plugins if ( array_key_exists( ‘edit’, $actions ) ) unset( $actions[‘edit’] );
      // Remove deactivate link for important plugins
      if ( array_key_exists( ‘deactivate’, $actions ) && in_array( $plugin_file, array( ‘gotmls/index.php’ ))) unset( $actions[‘deactivate’] );
      return $actions;

  2. darrinb says:

    WordPress also calls a filter hook on your plugin’s specific action links. So if you want to just target your plugin, just call it on your plugin’s specific action links like so:

    add_filter(“plugin_action_links_$plugin_file”, ‘disable_plugin_deactivation’), 10, 4 );

    Where “$plugin_file” is the folder/main file of your plugin.

    This way, you can leave other plugins alone.

  3. NowellVanHoesen says:

    @wpbeginnerotto42 understood. I only use mu-plugins for sites where I make custom widgets, post-types, or plugins for a specific client. Any updates should only be coming from me.

  4. wpbeginner says:

    @NowellVanHoesen Just got a respond from otto42 and he said that NO you cannot allow upgrades by dropping it into wp-content/mu-plugins/ folder….So he suggests that we use network activated plugins … which is useless for what we are trying to do here…

  5. wpbeginner says:

    @NowellVanHoesen Another issue is that you cannot put plugins in folders when you drop it into wp-content/mu-plugins/ folder… However @BillErickson mentioned that there is a patch for this in trac.

  6. wpbeginner says:

    @wp_smith nope @Billerickson is not sure either…. will ask @nacin and @otth42

  7. BillErickson says:

    @wpbeginner But I think there’s a patch for it (can’t find it on trac right now)

  8. BillErickson says:

    @wpbeginner I’m not sure, I only put plugins I write in there. Bigger issue is mu-plugins can’t be in folders (last time I checked)

  9. wp_smith says:

    @wpbeginner did u ever find this out?

  10. wpbeginner says:

    @billerickson can a user upgrade plugins if you drop it into mu-plugins without having to manually do it via FTP?

  11. NowellVanHoesen says:

    Good point, I will have to look into it

  12. wp_smith says:

    @billerickson @wpbeginner also include in the contract or TOS that if the user breaks the theme/site it’s their fault see

  13. wp_smith says:

    @billerickson still a neat trick though…lazy man’s way to design around a plugin! :)

  14. wp_smith says:

    @billerickson mu-plugins is my friend!

  15. BillErickson says:

    @wp_smith @wpbeginner Use mu-plugins or design the theme to not break if the plugin is disabled

  16. wpbeginner says:

    @NowellVanHoesen Wasn’t sure if you can upgrade plugins that are in wp-content/mu-plugins without having to go through a FTP client. If you can, then dropping plugins in wp-content/mu-plugins is certainly a better option.

  17. NowellVanHoesen says:

    Why not put the required plugins in wp-content/mu-plugins?

  18. edward.caissie says:

    Nice little trick … although not something I have a use for right away it’s definitely going into my bookmarks for future reference.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.