I have a function that i need to run every time a subscription status changes to active, This is my code:
add_action( 'woocommerce_subscription_status_active', array( __CLASS__,'add_subscription_course_access' ) );
public static function add_subscription_course_access( $order )
{
$products = $order->get_items();
$customer_id = $order->get_customer_id();
$courses_id = get_field('user-programs', 'user_'. $customer_id);
$courses_id = str_replace("[","",$courses_id);
$courses_id = str_replace("]","",$courses_id);
$courses_id = explode(",",$courses_id);
foreach ( $courses_id as $course_id ) {
ld_update_course_access( $customer_id, $course_id );
}
}
It works on localhost but on a live site its not working!