WordPress.org

Ready to get started?Download WordPress

Forums

Paid Memberships Pro
[resolved] PMP does not clean up after the uninstall process (7 posts)

  1. Caps
    Blocked
    Posted 2 years ago #

    The following tables are left after an uninstall.

    wp_pmpro_discount_codes
    wp_pmpro_discount_codes_levels
    wp_pmpro_discount_codes_uses
    wp_pmpro_membership_levels
    wp_pmpro_membership_orders
    wp_pmpro_memberships_categories
    wp_pmpro_memberships_pages
    wp_pmpro_memberships_users

    http://wordpress.org/extend/plugins/paid-memberships-pro/

  2. strangerstudios
    Member
    Plugin Author

    Posted 2 years ago #

    It's pretty dangerous to delete these tables when the plugin is deactivated. What if you were just testing something or deactivating during an update.

    That said, I could add some kind of "delete all data" button in the settings that would delete all data and deactivate the plugin. I've seen other plugins that do this.

  3. Caps
    Blocked
    Posted 2 years ago #

    The process as I stated was, uninstall = delete (sorry), which prompts do you want to delete all files. So those files are left after the delete process was finished.

  4. Ken Dirschl
    Member
    Posted 1 year ago #

    You can add an uninstall file that uses WP_UNINSTALL_PLUGIN to remove all database tables the plugin created. Will only happen on deletion of plugin, not on deactivation.

    // exit if uninstall/delete not called
    if (!defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN'))
        exit();
    
    // otherwise remove custom table
    global $wpdb;
    $tablename = $wpdb->prefix . "pmpro_membership_levels";
    // setup the query
    $sql = "DROP TABLE <code>$tablename</code>";
    // execute the query
    $wpdb->query($sql);
    
    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    dbDelta($sql);

    I think it's pretty safe to assume that if an administrator is deleting a plugin you can wipe the database.

  5. strangerstudios
    Member
    Plugin Author

    Posted 1 year ago #

    FYI, here is WP documentation on registering an uninstall hook or using an uninstall.php to uninstall:
    http://codex.wordpress.org/Function_Reference/register_uninstall_hook

    May be adding this to the plugin soon.

  6. strangerstudios
    Member
    Plugin Author

    Posted 1 year ago #

    Version 1.5.2 (not sure when it's coming, maybe end of the week) will have an uninstall.php that will remove the DB tables and PMPro options.

    Thanks.

  7. strangerstudios
    Member
    Plugin Author

    Posted 1 year ago #

    Marking this as resolved.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic