Skip to main content

benecaster_license_grace_started

Action Premium

Fires on the first transition of a license into a payment-failed grace window. Later rejections before recovery do not re-fire it — the clock starts once and does not reset, so this is the hook to hang a “your payment failed, you have 30 days” warning on.

Only a failed payment opens a grace window. A cancelled license and an unrecognised one do not, and neither fires this action.

Use it to publish an admin notice, alert an external monitoring service, or trigger a customer-facing email through a CRM.

Parameters

Name Type Default Description
$started_at int — Unix timestamp when the grace window opened (the time of the first payment_failed rejection)
$reason string — The `reason` field from the /validate response that opened the grace window. Currently always 'payment_failed'; reserved for future expansion.

Examples

Send an external alert when the payment-failed grace window opens

add_action( 'benecaster_license_grace_started', function ( int $started_at, string $reason ): void {
    wp_remote_post( MY_MONITORING_WEBHOOK, [
        'body' => wp_json_encode( [
            'event'      => 'license_grace_started',
            'reason'     => $reason,
            'started_at' => $started_at,
            'site'       => home_url(),
        ] ),
    ] );
}, 10, 2 );

Notes

The grace window lasts 30 days. Once it elapses, benecaster_license_payment_grace_hard_cutoff fires once and every active subscriber token is revoked. Recovery at any point is via benecaster_license_grace_recovered.

Need this built rather than just documented? See our services →