Skip to main content

CommunityPlatformInterface

Benecaster\Community\CommunityPlatformInterface

Interface Premium community-integrations

The interface a community platform integration must implement to join the Community Integrations add-on. Register your instance through the benecaster_community_platforms filter, keyed by platform slug.

This registration passes an object rather than an array of callbacks, and that is a deliberate exception. Benecaster’s two query-strategy registries take a label and one callable, because a strategy is a single question with a single answer. A community platform is a lifecycle contract — credentials that may not be present, three subscription methods that must agree with one another, and a separate episode-publish path — so it registers the way payment gateways do. Ruled 2026-09-03.

Once registered, the add-on routes every subscription event to your platform the same way it routes them to the built-in Discord and Circle integrations — activations, cancellations, tier changes, and episode publishes all arrive without being wired individually. That is the point of implementing the interface rather than listening to the hooks yourself: you get the whole lifecycle, and you stay in step with it as it grows.

Methods

Method Visibility Since Description
getSlug(): string Public Returns a unique identifier for this platform. Used as the registry key and in stored settings, so treat it as permanent — changing it orphans existing configuration.
isConfigured(): bool Public Returns whether the operator has finished setting the platform up — typically whether an API key is present. Return false and the platform is skipped silently rather than erroring on every event.
addMember( int $user_id, string $tier_slug ): bool Public Grants the subscriber access to the community at the given tier. Return false on failure. Called on activation and on any change that grants access.
removeMember( int $user_id ): bool Public Revokes the subscriber's community access. Return false on failure. Should be safe to call for somebody who is already absent.
updateMemberTier( int $user_id, string $old_tier, string $new_tier ): bool Public Moves an existing member between tiers. Both the old and new slugs are supplied so you can remove one role and add another where the platform has no single move operation.
onEpisodePublished( int $episode_id, int $show_id ): void Public Called when an episode is published — announce it, or do nothing. Returns void because an announcement failing is not a reason to fail the publish. Check isConfigured() first; this method is called whether or not the platform is set up.

Notes

Every method that talks to a remote API should fail soft. These are called during subscription lifecycle events, and an exception thrown here surfaces to the subscriber or the operator in the middle of an unrelated action.