Skip to main content

benecaster_validation_failure

Action Premium

Fires every day the Benecaster license server is unreachable due to a transport error — connection refused, timeout, or a 5xx response. The $failure_days counter increments by one each day the server remains unreachable and resets to zero on the next successful validation. The hook fires once per daily validation cycle for as long as the server is down.

This hook fires for network problems, not for explicit license rejections. For server-side rejections where the server responds and rejects the license, use benecaster_license_invalid instead. Grace period behavior: during days 1–14, premium features continue normally. On days 15–29, a random alert appears in the Benecaster admin dashboard. At 30 consecutive failure days, benecaster_license_hard_limit_reached fires and premium features are restricted.

Parameters

Name Type Default Description
$failure_days int — Number of consecutive days the server has been unreachable
$error_type string — One of `timeout`, `connection_refused`, `http_error`, or `unknown` — a best-effort classification of the transport failure. WordPress's HTTP transports report every transport failure under one generic error code, so the real cause is matched from the error message text. A callback registered with `accepted_args = 1` works unmodified and never receives this argument.
$status_code int|null — The HTTP status code when `$error_type` is `http_error`, otherwise `null`.

Examples

Slack alert on 7-day intervals

add_action( 'benecaster_validation_failure', function( int $failure_days ): void {
    if ( $failure_days < 7 || $failure_days % 7 !== 0 ) {
        return; // Only alert on multiples of 7 days.
    }
    wp_remote_post( MY_SLACK_WEBHOOK, [
        'body' => json_encode([
            'text' => sprintf(
                ':red_circle: Benecaster license server unreachable for %d consecutive days on %s.',
                $failure_days,
                home_url()
            ),
        ]),
        'headers' => [ 'Content-Type' => 'application/json' ],
    ] );
} );

Notes

The grace period provides up to 30 days before features are restricted: days 1–14 silent, days 15–29 intermittent admin alerts, day 30 triggers benecaster_license_hard_limit_reached.

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