Prevent a WordPress plugin from searching for updates

In this WordPress tutorial, we will learn how to prevent a WordPress plugin from searching for updates.

It can be found many times for developers that they modify a WordPress plugin to use it for their need. But here is the problem with those modified WordPress plugins available on wordpress.org. These plugins always search for updates and if new update available then it will show you the update available notice.

Suppose you have built a WordPress site for someone or for a client. If this update notification is shown to him/her and if he/she update the plugin then all the changes you made inside the plugin will disappear. So you need to stop searching for updates for that WordPress plugin to protect from losing modification that you made in that plugin.

Once I faced a problem with the custom meta box plugin CMB2. this is a framework and I built an audio directory plugin using this framework type plugin. One day I got the update notification for this plugin. I knew that it will erase all the modification that I did to built that plugin if I update it. So I did not update this plugin. I used the below code to stop searching my plugin for any updates. Here is the code:

PHP Code to Prevent WordPress Plugin Searching for updates

// Disable update
function filter_plugin_updates( $value ) {
    unset( $value->response['PATH_TO_PLUGIN_MAIN_FILE'] ); //Replace the path with main PHP file of your plugin.
    return $value;
}
add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );

Here “PATH_TO_PLUGIN_MAIN_FILE” is the path of main PHP file of the plugin. For my CMB2 plugin, it was cmb2/init.php. You have to replace it with your plugin’s main PHP file. The main PHP file of any plugins is the one which contains plugin name, author etc on the top.

How to use this code to prevent stop the WordPress plugin from searching for updates?

You can use this code in your theme’s functions.php file or in a separate plugin’s file. But the best suggestion is to use it inside that plugin’s main PHP file which you want to be stopped from searching for updates. It will work nicely and perfectly just as you want.

Also, read,

One response to “Prevent a WordPress plugin from searching for updates”

  1. Pradeep baj says:

    Hello.
    Where I can paste this code ?
    The main php file containing lot of coding.

    I have one more question
    I have downloaded a GPL thrive architect Plugin which is active and working fine but it’s showing update now and when I update it, Plugin become inactive.

    I have edited the updated Plugin licensemanager.php and Plugin is again active but when it recive any update again and I update it Plugin will again become inactive.

    1.How can I make it updateable?
    2.Where I can place above code you mentioned to stop receiving updates?

Leave a Reply

Your email address will not be published. Required fields are marked *