Skip to main content

Trigger push notifications when scheduled episodes unlock

Free Beginner Since v1.0.0

The availability check cron fires after each pass and reports how many tier/episode pairs just became available. When $unlocked_count > 0, new content just unlocked — use this as the trigger point for push notifications, cache warming, or social post scheduling without building your own scheduled availability check.

Code

<?php
add_action( 'benecaster_availability_check_run', function ( int $unlocked_count, array $rows ) {
    if ( $unlocked_count === 0 ) {
        return;
    }
    foreach ( $rows as $row ) {
        // $row has episode_id, show_id, tier_slug, available_datetime.
        my_push_service_notify_tier( (int) $row->show_id, (string) $row->tier_slug,
            'A new episode just unlocked for your tier!' );
    }
}, 10, 2 );

View on GitHub →

Hooks Used