Skip to main content

benecaster_license_expiring

Action Premium

Fires when a license is within 30 days of its expiry date. This hook fires once per successful daily validation response while the license remains in the expiry window — meaning it can fire every day for up to 30 consecutive days. The built-in license expiry notice in Benecaster’s admin settings fires independently of this hook.

It follows the licence’s expiry date (expires_at) alone. The move of a lapsed free academic licence to the free Launch plan does not fire it, and does not replace it: Benecaster’s admin screens switch to “moves to the free Launch plan on ” wording, but this hook does not change, and nothing suppresses it while that notice is showing. No separate hook exists for the academic move.

Use this hook to integrate expiry warnings into an external monitoring system, send renewal reminders via a third-party service, or trigger custom admin alerts.

Parameters

Name Type Default Description
$days_remaining int Whole days until the licence expires, rounded up; never below 0
$expires_at string The expiry datetime from the licence server (UTC, `Y-m-d H:i:s`)

Examples

Send Slack renewal reminder, once per month

add_action( 'benecaster_license_expiring', function( int $days_remaining, string $expires_at ): void {
    $sent_key = 'my_addon_expiry_slack_sent_' . date( 'Y-m' );
    if ( get_transient( $sent_key ) ) {
        return; // Already sent this month
    }
    wp_remote_post( MY_SLACK_WEBHOOK, [
        'body' => json_encode([
            'text' => sprintf(
                ':calendar: Benecaster license expires in %d days (%s). Renew at benecaster.com.',
                $days_remaining,
                $expires_at
            ),
        ]),
        'headers' => [ 'Content-Type' => 'application/json' ],
    ] );
    set_transient( $sent_key, true, WEEK_IN_SECONDS );
}, 10, 2 );

Notes

This hook fires every day the license is within the 30-day expiry window, not just once. Guard with idempotency — for example, a transient keyed on year-month — if you only need to act once per period.

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