benecaster_availability_datetimes
Filters the tier-slug-to-datetime map before episode availability rows are written. Return the array — a tier_slug => 'Y-m-d H:i:s' map. Add, remove or re-time any entry.
⚠ The datetimes here are SITE-LOCAL, not UTC. AvailabilityRepository::upsert() converts once on the way into the database, so returning a UTC value shifts every affected episode by the site’s offset, silently and in the wrong direction. This is the one rule to get right in a callback here.
⚠ Follower rows are stripped AFTER this filter runs, deliberately — adding a follower entry here will not survive, because followers are a marketing list with a feed URL rather than a tier. Returning an empty array writes no rows at all rather than restoring defaults.
Vary early access per tier when availability is set
benecaster_availability_datetimes fires before any availability row is written for an episode, so a callback can give one tier an earlier unlock than the editor typed, or drop a tier from an episode entirely.
<?php
add_filter( 'benecaster_availability_datetimes', function ( array $tier_datetimes, int $episode_id, int $show_id ): array {
// Founding members get everything three days before everyone else.
if ( isset( $tier_datetimes['gold'] ) ) {
$tier_datetimes['founding'] = gmdate(
'Y-m-d H:i:s',
strtotime( $tier_datetimes['gold'] . ' -3 days' )
);
}
return $tier_datetimes;
}, 10, 3 );
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$tier_datetimes |
array |
— | tier_slug => 'Y-m-d H:i:s' map, in the site's local timezone. |
$episode_id |
int |
— | Episode whose availability is being set. |
$show_id |
int |
— | Show the episode belongs to. |
Returns:
array
Need this built rather than just documented? See our services →