Skip to main content

benecaster_license_payment_grace_recovered

Action Free Since v1.2.0

Fires when a Day-30 hard cutoff is cleared and subscriber tokens are restored — that is, when payment succeeds after feeds had already gone dark. Carries the number of tokens actually un-revoked.

Distinct from benecaster_license_grace_recovered, which fires on every recovery including one where payment landed inside the window and no subscriber ever lost access. Hook the general one to dismiss an admin notice; hook this one when the distinction matters — an outage genuinely ended and people got their access back.

Restoration is scoped: only tokens tagged grace_timeout come back. Tokens revoked during the same window for any other reason — an admin revoking access, a bridge cancellation, a manual grant expiring — stay revoked, so $restored_count reflects the cutoff cohort rather than every revoked token on the site.

Parameters

Name Type Default Description
$restored_count int Number of tokens un-revoked by this recovery.
$started_at int Unix timestamp when the grace window originally opened — subtract from the current time for total outage duration.

Examples

Resolve a monitoring incident when access returns

add_action( 'benecaster_license_payment_grace_recovered', function ( int $restored_count, int $started_at ): void {
    $hours = (int) round( ( time() - $started_at ) / HOUR_IN_SECONDS );

    wp_remote_post( MY_ALERT_WEBHOOK, [
        'body' => wp_json_encode( [
            'event' => 'resolve',
            'text'  => sprintf(
                'Benecaster access restored — %d subscriber%s back after %d hours.',
                $restored_count,
                1 === $restored_count ? '' : 's',
                $hours
            ),
        ] ),
    ] );
}, 10, 2 );

Notes

Fires once per recovery, on the validation cycle that clears the cutoff. It does not fire on the pre-Day-30 pay-and-recover path — nothing was revoked there, so there is nothing to report. A $restored_count of 0 is possible if every token had already been revoked for another reason before the cutoff ran.