Skip to main content

Override subscriber count from an external analytics source

Free Beginner Since v1.0.0

When your source of truth for subscriber counts is external — a hosting platform, payment processor, or BI tool — override benecaster_get_subscriber_count() to return the external figure. Cache aggressively. Note: the returned count affects upgrade threshold calculations, so fall back to Benecaster’s count on cache miss rather than returning zero.

Code

<?php
add_filter( 'benecaster_analytics_subscriber_count', function ( int $count, int $show_id ): int {
    $external = (int) get_transient( 'my_subscriber_count_' . $show_id );
    return $external > 0 ? $external : $count; // fall back to Benecaster count on cache miss
}, 10, 2 );

View on GitHub →

Hooks Used