Skip to main content

benecaster_license_grace_recovered

Action Premium

Fires when a license goes valid again and closes an open payment-failed grace window. It completes the grace lifecycle alongside benecaster_license_grace_started and benecaster_license_grace_expired.

By the time your callback runs the recovery is already done. If the day-30 cutoff had fired, every token revoked with a grace_timeout reason has been restored and full private-feed access returns on each subscriber’s next poll — same feed URLs, nothing for the subscriber to do. If payment landed inside the window, no token was ever revoked and nothing needed restoring. Either way there is nothing to undo here — only things to tell people.

Use it to dismiss any grace notice you published, send a “you’re back” email, or record how long the window stayed open.

Parameters

Name Type Default Description
$started_at int — Unix timestamp when the grace window was originally opened
$duration_seconds int — Elapsed grace time in seconds (now − started_at), clamped to zero on server clock drift. Divide by DAY_IN_SECONDS to get days elapsed.

Examples

Send a recovery notification when the license returns to valid

add_action( 'benecaster_license_grace_recovered', function ( int $started_at, int $duration_seconds ): void {
    $days = intdiv( $duration_seconds, DAY_IN_SECONDS );
    wp_remote_post( MY_ALERT_ENDPOINT, [
        'body' => wp_json_encode( [
            'event'            => 'license_grace_recovered',
            'grace_days'       => $days,
            'recovered_at'     => time(),
            'site'             => home_url(),
        ] ),
    ] );
}, 10, 2 );

Notes

This action fires at most once per grace window, the moment recovery is detected, and on every recovery — both the pay-inside-the-window path and the post-cutoff one. By the time it fires, any revoked tokens have been restored and private feeds are live again; no additional action is needed to restore access.

To act only when an outage genuinely ended, hook benecaster_license_payment_grace_recovered instead — it fires only after a cutoff and carries the number of tokens actually brought back.

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