Skip to main content

Public Functions Reference

Public PHP functions provided by Benecaster core. These functions are safe to call from add-ons and custom code — they are stable, versioned contracts.

All functions listed here are Free unless otherwise noted.


Episode Access

Function Signature Description
benecaster_user_can_access_episode() ( int $episode_id, int $show_id, int $user_id = 0 ): bool Returns true if the given user can access the episode at their current tier. Pass $user_id = 0 (or omit) to check the currently logged-in user. Returns true for public episodes regardless of user. Free.
benecaster_get_user_tier_for_show() ( int $show_id, int $user_id = 0 ): string|null Returns the Benecaster internal tier slug for the given user’s active subscription on the show, or null if the user has no active token. Pass $user_id = 0 (or omit) to check the currently logged-in user. Free.

Note on argument order: Both functions place the object-specific ID first ($episode_id or $show_id) and $user_id last with a default of 0. Earlier planning documents showed a different order — the implemented signatures above are the canonical ones.


License

Function Signature Description
benecaster_is_premium() (): bool Returns true when the site has an active paid license. Premium features should gate behind this function rather than checking license status directly.
benecaster_get_license_plan() (): string|null Returns the current plan slug ('launch', 'starter', 'growth', 'pro', 'multi-show', 'studio') or null when no license is active.
benecaster_addon_is_active() ( string $addon_slug ): bool Returns true when the specified add-on is installed, active, and licensed (or when the site is on Studio plan, which includes all add-ons).
benecaster_is_upgrade_required() (): bool Returns true when the site is on the Launch plan and has reached the 10-subscriber cap. Safe to call on every request — reads from the local benecaster_license_upgrade_required option, no HTTP call.
benecaster_get_next_renewal_date() (): string|null Returns the ISO 8601 renewal date from the last validation response, or null for Launch/Free plans and before the first validation run.
benecaster_get_plan_label() ( string $slug ): string Returns the human-readable display name for a plan slug (e.g. 'growth''Growth'). Falls back to titlecasing the slug on catalog cache miss.
benecaster_get_addon_label() ( string $slug ): string Returns the human-readable display name for an add-on slug (e.g. 'email-editor''Email Editor'). Falls back to titlecasing the slug on catalog cache miss.
benecaster_get_referral_code() (): string|null Returns the current customer’s referral code, or null when the license server has not yet supplied one.
benecaster_get_referral_link() (): string|null Returns the full referral URL (e.g. https://benecaster.com/ref/XXXXXX), or null when no referral code is available.
benecaster_get_referral_credit_cents() (): int Returns the pending referral credit balance in cents (0 when no credit is pending).

Content

Function Signature Description
benecaster_get_show_description() ( int $show_id, string $type = 'short' ): string Returns the show description. $type = 'short' returns the Short description field (_benecaster_show_description_short), falling back to truncated post_content (tags stripped, 4,000 char limit) when empty. $type = 'full' returns the raw post_content. Filterable via [benecaster_show_description](/docs/benecaster_show_description/). Free.
benecaster_get_episode_description() ( int $episode_id ): string Returns the episode description (post_excerpt when set, otherwise post_content). Filterable via [benecaster_episode_description](/docs/benecaster_episode_description/). Free.
benecaster_get_latest_episode_id() ( int $show_id ): int|null Returns the ID of the most recently published episode for the given show, or null when the show has no published episodes. Free.

Custom Fields

Function Signature Description
benecaster_register_field_cpt() ( string $cpt_slug, string $label ): void Register a custom post type with Benecaster’s field system so it can host field groups
benecaster_get_field() ( int $field_id, int $object_id ): mixed Get the stored value for a single custom field on an object
benecaster_get_fields() ( int $object_id, string $cpt_slug ): array Get all custom field values for an object