Last active
March 20, 2024 11:48
-
-
Save dryan1144/c971b590e046b2d818ca46f9a8702227 to your computer and use it in GitHub Desktop.
Subscription update callback for Recurring Payments EDD extension
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 | |
/*** | |
Make API call if Recurring Payments subscription status has changed | |
**/ | |
add_action( 'edd_recurring_update_subscription', 'drw_subscription_update_callback', 10, 1); | |
function drw_subscription_update_callback( $subscription_id = null ) { | |
if ( null == $subscription_id ) return; | |
$subscription = new EDD_Subscription( $subscription_id ); | |
$user_id = $subscription->customer->user_id; | |
//'pending', 'active', 'cancelled', 'expired', 'failing', 'completed' | |
$status = $subscription->get_status(); | |
if ( 'cancelled' || 'expired' == $status ) { | |
// make API call | |
} elseif( 'active' == $status ) { | |
// make API call | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment