Last active
February 19, 2024 18:58
-
-
Save kimcoleman/e930d330a4be2938ac2b5058e1b217f9 to your computer and use it in GitHub Desktop.
Optional database updates to drop orphaned orders table columns and unused usermeta rows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Optional database updates to drop orphaned orders table columns and unused usermeta rows. | |
*/ | |
function run_optional_pmpro_upgrade_3_0() { | |
global $wpdb; | |
// PMPro Stripe Billing Limits Add On has been merged into core and no longer needs `pmpro_stripe_billing_limit` user meta. | |
$sqlQuery = " | |
DELETE FROM {$wpdb->usermeta} | |
WHERE meta_key = 'pmpro_stripe_billing_limit' | |
"; | |
$wpdb->query( $sqlQuery ); | |
// Dropping deleted order columns. | |
$columns_to_drop = array( | |
'couponamount', | |
'certificate_id', | |
'certificateamount', | |
); | |
foreach ( $columns_to_drop as $column ) { | |
$sqlQuery = " | |
ALTER TABLE {$wpdb->pmpro_membership_orders} | |
DROP COLUMN {$column} | |
"; | |
$wpdb->query( $sqlQuery ); | |
} | |
} | |
add_action( 'admin_init', 'run_optional_pmpro_upgrade_3_0' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment