0

Is it possible to block specific plugins from updating, manually too? I don't want to block this by hiding the notification, changing the plugin version or anything like this. I'd like the notification to show, show the new version number, but when hitting the update manually it should block/disallow this - preferably displaying some sort of (cusomized) notification in the plugin section (eg. "Update for this plugin is not possible").

3
  • if it's a free plugin of wordpress.org, you juste have to rename the directory name of the plugin. – Kaperto Nov 26 '19 at 12:38
  • I was more looking into commercial plugins. – Chris Osiak Nov 26 '19 at 15:26
  • there is a lot of different way to update a commercial plugin then you have to read the code of the plugin to find how to stop the update. – Kaperto Nov 26 '19 at 18:01
0

Try this:

add_filter( 'http_request_args', 'dm_prevent_update_check', 10, 2 );
function dm_prevent_update_check( $r, $url ) {
    if ( 0 === strpos( $url, 'http://api.wordpress.org/plugins/update-check/' ) ) {
        $my_plugin = plugin_basename( __FILE__ );
        $plugins = unserialize( $r['body']['plugins'] );
        unset( $plugins->plugins[$my_plugin] );
        unset( $plugins->active[array_search( $my_plugin, $plugins->active )] );
        $r['body']['plugins'] = serialize( $plugins );
    }
    return $r;
}

Credits: https://stackoverflow.com/questions/17897044/wordpress-how-to-disable-plugin-update

2
0

Assuming you are still planning on updating plugins yourself but don't want other users to be able to do it, according to wp-admin/update.php you can revoke the 'update_plugins' permission from a user to prevent this. They will get a wp_die message 'Sorry, you are not allowed to update plugins for this site.'

For permissions management you can use User Role Editor or similar.

2
  • Well, I'd need that option for admins as well. Deciding by role is nice and easy, but I need to achieve the same, but for all users. If I ever want to update plugins myself, I'd have to delete the extra code I've put there for this block to work... – Chris Osiak Nov 26 '19 at 22:23
  • Put every other admin but you in a lesser role without upgrade privilages. It seems like you're making this more complicated than it needs to be. – Andrew Nov 27 '19 at 4:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.