How to Keep Clients from Deactivating Your WordPress Plugins

How to Keep Clients from Deactivating Your WordPress Plugins

Do you want to learn how to prevent clients from deactivating your WordPress plugins? This post is for you. When building a website for a client one of the problems you will have to deal with is that of clients deactivating the plugins you have installed and activated. This will lead to performance issues that will keep clients calling you for help. To keep clients from deactivating your must-have WordPress plugins accidentally there are a number of things you can do.

Prevent plugin deactivation by using a plugin

This is the first method you should consider. It is easy and less intrusive. Users with administrator roles will have full control and can turn it off if they want. For this to work you need a plugin that removes the ‘Deactivate’ link from the installed plugins. Yes users will be able to install new plugins. The best plugin to help keep clients from deactivating your WordPress plugins is the Disable Plugin Deactivation plugin. Install and activate this plugin. You then need to go to Plugins>>Plugin Deactivation Settings page in order to configure the plugin options.

From this page you need to click on, ‘Enable’ next to the ‘Disable Plugin Deactivation’ option. This will turn off the plugin ‘Deactivate’ link from all the installed plugins. You can also use this plugin to disable plugin activation if you don’t want users to activate other plugins. It is also possible to turn off plugin deletion and prevent users from installing updates to the plugins. You should, however, never turn off plugin updates as doing so will compromise the security of your WordPress website. Save the changes once you are done. The only downside with this option is that users can go to Plugins>>Plugin Deactivation Settings page and disable this feature.

Prevent specific plugins from being deactivated

If you don’t want a specific plugin to be deactivated then this is the method you need to use. You have to add code to your website for this to work. Locate the plugin you don’t want to be deactivated. The plugins are located in the wp-content folder and you can find them by connecting to the WordPress hosting account using FTP client. Find the plugin file named after your target plugin. It will have a .php extension. Add this code to the theme’s functions.php file or the site-specific plugin.

add_filter( ‘plugin_action_links’,
‘disable_plugin_deactivation’, 10, 4 );
function disable_plugin_deactivation( $actions, $plugin_file, $plugin_data, $context ) {
if ( array_key_exists( ‘deactivate’, $actions ) && in_array( $plugin_file, array(
‘wpforms/wpforms.php’,
‘woocommerce/woocommerce.php’
)))
unset( $actions[‘deactivate’] );
return $actions;
}

In the above code, deactivation is for two plugins, WooCommerce and WPForms. You add the plugins by mentioning their location in the plugins folder. For example wpforms/wpforms.php

Replace the plugin locations with your own. This method only affects the crucial plugins. The client will still be able to deactivate other plugins, install new ones, delete other and update all plugins.

Prevent clients from deactivating your WordPress plugins