Skip to main content

Trigger push notifications when scheduled episodes unlock

Premium Beginner

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.

To tell a tier about a new episode, use Notify a tier once when an episode opens to it instead. $rows here is only what the scheduled check saw: it misses a tier that can hear the episode the moment it is published, and it can list rows that were already announced at publish. Use this hook for cache warming or a summary.

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

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