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
| Parameter | Type | Description |
|---|---|---|
$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
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Since
This hook was added in Stripe version 2.1.
Source Code
This hook is located in GFStripe::cancel() in class-gf-stripe.php.