Created
February 16, 2022 15:17
-
-
Save andrewlimaza/c024a75fd731d5ed1b21c728c378f171 to your computer and use it in GitHub Desktop.
Clear Stripe level meta data [Script]
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 | |
/** | |
* 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