Skip to main content

benecaster_invalid_token_alert_threshold

Filter Free

Per-show threshold and window for the “Unusual failed feed access” security alert. Called by Security\InvalidTokenMonitor once per counted failure — only for requests whose token matched no subscriber row, never for valid, revoked, or anonymous requests, so the filter costs nothing on ordinary feed traffic.

Off means off: returning false or null stops counting for the show entirely — nothing is stored, benecaster_invalid_token_recorded does not fire, and no alert is raised.

Any other non-array return falls back to the defaults, deliberately: a filter that breaks (returns a string, forgets to return) must not silently disable a security alarm. Missing keys fall back individually. count is clamped to at least 1; window_minutes to 1–1440 (one day — the counter keeps per-minute buckets, so this also bounds its storage).

⚠ Not governed by this filter: the 24-hour cooldown after an alert and the one-hour quiet period after dismissing one.

Tune invalid token alerts per show

Free Beginner

The “Unusual failed feed access” alert defaults to 10 unknown-token requests in 60 minutes, per show. A show with a large audience and a lot of mis-copied URLs may need a higher bar before it’s worth an alert; a show you use for testing may not want the alert at all.

benecaster_invalid_token_alert_threshold receives the show ID, so tuning can target specific shows rather than the whole install. Returning false or null switches monitoring off for that show entirely — no counting, no benecaster_invalid_token_recorded, no alert. Any other non-array return falls back to the defaults, so a bug in your callback can’t silently disable the alarm.

<?php
add_filter(
    'benecaster_invalid_token_alert_threshold',
    function ( array $config, int $show_id ) {
        // A staging or test show: no monitoring at all. Returning false
        // also stops benecaster_invalid_token_recorded for this show.
        if ( 123 === $show_id ) {
            return false;
        }

        // A high-traffic show: only alert on a heavier burst, over a
        // shorter window.
        if ( 456 === $show_id ) {
            return [ 'count' => 50, 'window_minutes' => 30 ];
        }

        return $config;
    },
    10,
    2
);

View on GitHub →

Parameters

Name Type Default Description
$config array `[ 'count' => 10, 'window_minutes' => 60 ]` by default — alert when `count` feed requests using a token that matches no subscriber arrive within `window_minutes`.
$show_id int ID of the show being evaluated.

Returns: array|false|null

Example

add_filter( 'benecaster_invalid_token_alert_threshold', function ( array $config ): array {
    // Raise the threshold for every show at once.
    $config['count'] = 25;
    return $config;
} );

Notes

A one-argument callback that ignores $show_id works — register with accepted_args 1 to change every show at once. See the recipe above for per-show tuning, including switching a show off entirely.

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