Skip to main content

benecaster_benchmarks_refreshed

Action Free

Fires after a successful benchmark refresh writes updated industry data to the WordPress transient cache. The transient is already written before callbacks run — reading the benchmark data from within a callback returns the newly refreshed values.

This hook does not fire when a refresh is skipped via [benecaster_benchmarks_fetch_skip](/hooks/benecaster_benchmarks_fetch_skip/), when the HTTP request to the license server fails, or when the response fails validation. The `$payload` array is the data as written to the transient, including any normalization applied during the fetch. Treat unknown keys as forwards-compatible additions.

Examples

Purge a page cache on benchmark update

add_action(
    'benecaster_benchmarks_refreshed',
    function ( array $payload ): void {
        delete_transient( 'my_plugin_analytics_page_cache' );

        if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
            error_log( sprintf(
                '[Benecaster] Benchmarks refreshed. Schema version: %d. Refreshed at: %s.',
                $payload['schema_version'] ?? 0,
                $payload['refreshed_at'] ?? 'unknown'
            ) );
        }
    }
);

Notify an external monitoring service

add_action(
    'benecaster_benchmarks_refreshed',
    function ( array $payload ): void {
        wp_remote_post(
            'https://monitoring.example.com/webhooks/benecaster-benchmarks',
            [
                'body'     => wp_json_encode( [
                    'event'          => 'benchmarks_refreshed',
                    'refreshed_at'   => $payload['refreshed_at'] ?? null,
                    'schema_version' => $payload['schema_version'] ?? null,
                ] ),
                'headers'  => [ 'Content-Type' => 'application/json' ],
                'timeout'  => 3,
                'blocking' => false,
            ]
        );
    }
);

Notes

Modifications to $payload inside a callback have no effect on the cached transient value — this is an action, not a filter. Use benecaster_benchmarks_fetch_skip to prevent a refresh from running.