You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

重做WordPress.org发布的插件后,如何禁用老用户的自动更新?

Hey there, I’ve dealt with similar plugin rewrite scenarios before, so here’s a solid plan to disable auto-updates for your old plugin version and keep existing users on it without forcing the new rewrite:

1. Push a final "disable update" patch to your old plugin (best approach)

If you can still release one last minor update for your old plugin, this is the cleanest way to roll out the disable logic to all existing users. Add this code to your old plugin’s main PHP file:

// Disable auto-updates for this old plugin version
add_filter('site_transient_update_plugins', 'block_old_myplugin_updates');

function block_old_myplugin_updates($transient) {
    // Replace with your plugin's slug (e.g., if your plugin folder is "my-old-plugin", use that)
    $target_plugin_slug = 'your-old-plugin-slug';
    $plugin_main_file = $target_plugin_slug . '/' . $target_plugin_slug . '.php';

    // Remove any pending update entry for our plugin
    if (isset($transient->response[$plugin_main_file])) {
        unset($transient->response[$plugin_main_file]);
    }

    return $transient;
}

This code hooks into WordPress's plugin update check system and removes any update notification for your old plugin. Once users install this final patch, they’ll never see or get auto-pushed to your new rewrite.

2. Fallback: Guide users to manually disable updates

If you can’t push a final patch to the old plugin, share these options with your existing users:

  • Add code to their theme’s functions.php: Have them paste the same code above into their active theme’s functions.php file (remind them to replace the plugin slug with yours).
  • Use a custom "disable update" plugin: Create a tiny standalone plugin that only contains the code above, and ask users to install it. This avoids messing with their theme files.
Key Notes to Remember
  • Be transparent: Clearly inform users that continuing to use the old version means they’re taking on compatibility and security risks. Add a notice in the old plugin’s admin dashboard to communicate this.
  • Slug consistency: If your new plugin uses the same slug as the old one, this code is critical—WordPress will otherwise automatically push the new version to everyone. If you used a new slug for the rewrite, you might still want to add this to prevent confusion for users who stick with the old version.

内容的提问来源于stack exchange,提问作者rajesh singh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 07:56:28