Created
December 10, 2020 07:28
-
-
Save ericnicolaas/62cd6f1d652d86ffab6d5994334a26ab to your computer and use it in GitHub Desktop.
Delete all pending donations in a date rnage
This file contains 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 | |
/** | |
* Adjust the before/after variables to limit the deletion to | |
* a specific date range. If you want to delete all, set a very | |
* early $before date (i.e. '2000-01-01'). | |
*/ | |
add_action( 'admin_init', function() { | |
$after = '2020-11-01'; | |
$before = '2020-11-30'; | |
$query = new Charitable_Donations_Query( | |
array( | |
'output' => 'ids', | |
'status' => array( 'charitable-pending' ), | |
'number' => -1, | |
'date_query' => array( | |
array( | |
'before' => $before, | |
'after' => $after, | |
'inclusive' => true, | |
) | |
), | |
) | |
); | |
foreach( $query->get_donations() as $donation ) { | |
wp_delete_post( $donation->ID ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To delete recurring donations, you can use the following: