Description
The gform_stripe_subscription_cancel_at_period_end filter can be used to delay the cancellation of the subscription until the end of the current period.
Usage
The hook which would run for all Stripe feeds can be used like so:
add_filter( 'gform_stripe_subscription_cancel_at_period_end', 'your_function_name', 10, 3 );
Parameters
- $at_period_end bool
Defaults to false, subscription will be cancelled immediately.
-
$entry Entry Object
The entry from which the subscription was created.
-
$feed Feed Object
The feed object which processed the current entry.
Examples
1. Apply to all subscriptions
add_filter( 'gform_stripe_subscription_cancel_at_period_end', '__return_true' );
2. Apply to a specific feed
The following example shows how you can delay the subscription cancellation for a specific feed by checking the feed name.
add_filter( 'gform_stripe_subscription_cancel_at_period_end', 'stripe_subscription_cancel_at_period_end', 10, 3 ); function stripe_subscription_cancel_at_period_end( $at_period_end, $entry, $feed ) { $feed_name = rgars( $feed, 'meta/feedName' ); if ( $feed_name == 'your feed name here' ) { return true; } return $at_period_end; }
Placement
Your code snippet should be placed in the functions.php file of your active theme.
Since
This hook was added in Stripe version 2.1.
Source Code
$params['at_period_end'] = apply_filters( 'gform_stripe_subscription_cancel_at_period_end', false, $entry, $feed );
This hook is located in GFStripe::cancel() in class-gf-stripe.php.