Skip to content

Instantly share code, notes, and snippets.

@dryan1144
Last active March 20, 2024 11:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dryan1144/c971b590e046b2d818ca46f9a8702227 to your computer and use it in GitHub Desktop.
Save dryan1144/c971b590e046b2d818ca46f9a8702227 to your computer and use it in GitHub Desktop.
Subscription update callback for Recurring Payments EDD extension
<?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