Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created February 16, 2022 15:17
Show Gist options
  • Save andrewlimaza/c024a75fd731d5ed1b21c728c378f171 to your computer and use it in GitHub Desktop.
Save andrewlimaza/c024a75fd731d5ed1b21c728c378f171 to your computer and use it in GitHub Desktop.
Clear Stripe level meta data [Script]
<?php
/**
* Clear any unnecessary Stripe data from level meta table that may be causing checkout issues.
*
* To run this code add it to your WordPress website by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Once installed, add ?clean_stripe=1 to any URL while logged-in as an admin.
*
* After running this script, please delete it from your site.
*
* @return void
*/
function remove_stripe_level_metadata() {
if ( isset( $_REQUEST['clean_stripe'] ) && current_user_can( 'manage_options' ) ) {
$all_levels = pmpro_getAllLevels();
foreach( $all_levels as $level ) {
delete_pmpro_membership_level_meta( $level->id, 'stripe_product_id' );
delete_pmpro_membership_level_meta( $level->id, 'stripe_product_id_sandbox' );
}
}
}
add_action( 'init', 'remove_stripe_level_metadata' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment