Support » Plugin: Subscribe2 » Uninstall on Multisite

  • Resolved jkbb



    We hade no use for this plugin anymore so I deactivated and removed it. I read that there is an uninstall script that’s supposed to run when doing this. But doesn’t seem to work since I still have a lot of subscribe2 related stuff in my db. For example I still got the subscribe2 table for each blog.

    How can i do a proper uninstallation of this script on my big mu installation?

Viewing 6 replies - 1 through 6 (of 6 total)
  • @jkbb,

    Thanks for raising this, I’ve looked at the uninstall code and it clearly isn’t robust enough to uninstall settings on Multisite installs as it doesn’t switch between database tables.

    Basically, the code need to cycle through all the sub-blog tables removing the settings. I haven’t tested this uninstall.php code but it’s worth a try:

    if ( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') ) {
    	// Make sure not to call this file directly
    } else {
    	// Is this WordPressMU or not?
    	if ( isset($wpmu_version) || strpos($wp_version, 'wordpress-mu') ) {
    		$s2_mu = true;
    	if ( function_exists('is_multisite') && is_multisite() ) {
    		$s2_mu = true;
    	if ( $s2_mu ) {
    		global $wpdb;
    		$blogs = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}");
    		foreach ( $blogs as $blog ) {
    	} else {
    	function s2_uninstall() {
    		global $wpdb, $table_prefix;
    		// get name of subscribe2 table
    		$public = $table_prefix . "subscribe2";
    		// delete entry from wp_options table
    		// delete legacy entry from wp-options table
    		// remove and scheduled events
    		// delete usermeta data for registered users
    		// use LIKE and % wildcard as meta_key names are prepended on WPMU
    		// and s2_cat is appended with category ID integer
    		$wpdb->query("DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_cat%'");
    		$wpdb->query("DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_subscribed'");
    		$wpdb->query("DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_format'");
    		$wpdb->query("DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_autosub'");
    		// delete any postmeta data that supressed notifications
    		$wpdb->query("DELETE from $wpdb->postmeta WHERE meta_key = 's2mail'");
    		// drop the subscribe2 table
    		$sql = "DROP TABLE IF EXISTS <code>&quot; . $public . &quot;</code>";
    	} // end s2_uninstall()

    Thank you for the quick answer.

    So how do I use this, do I have to install, activate and deactivate the plugin again?


    You could install the plugin as normal, copy the code above over the existing uninstall.php file and then uninstall it (don’t even need to activate it).

    Or, if you can handle code okay you could simply run this code by adding it into an existing plugin or the functions.php file of your theme.

    Seemed to work great, except a reference to subscribe2/subscribe2.php in each blogs wp_options, _transient_plugin_slugs.



    Thanks for the feedback, I’ll update the uninstall.php file in the next version.

    The _transient keys are coming from the WordPress core files, there seems to be a way to stop the expired keys building up:

    WordPress _transient buildup


    In fact, after a little more digging, this seems to be a core bug in WordPress:

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Uninstall on Multisite’ is closed to new replies.