Created
March 25, 2015 06:56
-
-
Save KingYes/ea37c78666e25e6a7432 to your computer and use it in GitHub Desktop.
Fixes EDD Software Licenses - Past payments after EDD Upgrade to v2.3
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 | |
global $wpdb; | |
$license_ids = $wpdb->get_col( | |
"SELECT `post_id` FROM {$wpdb->postmeta} | |
WHERE `meta_key` LIKE '_edd_sl_user_id' | |
AND `meta_value` = '0';" | |
); | |
if ( ! empty( $license_ids ) ) { | |
$payment_ids = array(); | |
foreach ( $license_ids as $license_id ) { | |
$payment_id = get_post_meta( $license_id, '_edd_sl_payment_id', true ); | |
if ( in_array( $payment_id, $payment_ids ) ) | |
continue; | |
$payment_ids[] = $payment_id; | |
} | |
foreach ( $payment_ids as $payment_id ) { | |
edd_software_licensing()->update_licenses_on_payment_update( $payment_id ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment