I have a subscription that controls a CPT item’s premium status. I am using GravityForms along with it’s stripe gateway. I have this current code I’ve made:
add_action( 'gform_subscription_canceled', 'remove_premium_status', 10, 3 );
function remove_premium_status( $entry, $feed, $transaction_id ) {
$contractor_id = rgar( $entry, '9' );
$payment_date = rgar( $entry, 'payment_date' );
$downgrade_date = date('Y-m-d H:i:s', strtotime('+5 minutes', $payment_date));
$current_date_time = date('Y-m-d H:i:s');
if ( $contractor_id && $current_date_time > $downgrade_date) {
update_post_meta( $contractor_id, 'premium-contractor', 'false', 'true');
}
}
This works great without the AND condition as it cancels right away. Issue is, I want it to cancel at the end of the payment period. Right now I have it set to +5 minutes for testing. When I go to cancel and the “$current_date_time > $downgrade_date” is in place in the if statement it never ends up canceling. The $payment_date variable is already in the same format as the other two dates. Is there something else I should add to get this to cancel the second the timer is up?
Any help would be appreciated!
Tried to add the AND condition to check if the Current Time is greater than the Downgrade time set from the payment date. If both conditions are true it should perform the action (which was tested alone and works). If the > gets reversed it works but cancels immediately which is not what we want.