benecaster_get_episode_available_at()
benecaster_get_episode_available_at( int $episode_id, string $tier_slug ): ?string
Returns when an episode becomes available to a tier, so a theme can tell a member when a locked episode opens for them.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
episode_id |
int |
— | Yes | The episode (post) ID. |
tier_slug |
string |
— | Yes | A tier slug, or a buy-up's slug when the episode requires that buy-up. |
Return Value
Type:
string|null
When the episode opens to that tier, as a UTC Y-m-d H:i:s string, or null when the episode has no availability set for that slug. A time in the future means it is scheduled and not open yet.
Example
$opens = benecaster_get_episode_available_at( get_the_ID(), 'gold' );
if ( null !== $opens && strtotime( $opens . ' UTC' ) > time() ) {
printf(
esc_html__( 'Opens for Gold members on %s', 'my-theme' ),
esc_html( wp_date( get_option( 'date_format' ), strtotime( $opens . ' UTC' ) ) )
);
}
Notes
The value is in UTC. Convert it for display with wp_date() or get_date_from_gmt(), never date_i18n(), which shifts it by the site's offset a second time.
It answers "when", not "may this person listen". To decide access, use benecaster_user_can_access_episode().
Need this built rather than just documented? See our services →