Skip to main content

Integrate a community platform not in the Benecaster set

Premium Advanced

Implement CommunityPlatformInterface in your add-on and register the instance through the benecaster_community_platforms filter. The Community Integrations add-on routes all subscription events to every registered platform automatically — including Discord and Circle — so your platform receives activations, cancellations, and episode publish events without wiring them individually.

isConfigured() is not decoration — it is what stops the registry calling you. A platform that returns false is skipped entirely rather than dispatched to and left to fail. Return false while credentials are missing, expired or unverified, and the podcaster sees a platform that is quietly inactive instead of one that throws on every subscription event.

onEpisodePublished() is a different event stream from the other three — episode lifecycle, not subscription lifecycle — and an empty body is a correct implementation. Leave it empty rather than omitting it; the interface requires it either way.

Code

<?php
class MyPlatform implements \Benecaster\Community\CommunityPlatformInterface {

    public function getSlug(): string { return 'my-platform'; }

    public function isConfigured(): bool {
        return (bool) get_option( 'my_platform_api_key' );
    }

    public function addMember( int $user_id, string $tier_slug ): bool {
        $email = get_userdata( $user_id )->user_email;
        return my_platform_api_add_member( $email, $tier_slug );
    }

    public function removeMember( int $user_id ): bool {
        $email = get_userdata( $user_id )->user_email;
        return my_platform_api_remove_member( $email );
    }

    public function updateMemberTier( int $user_id, string $old_tier, string $new_tier ): bool {
        $email = get_userdata( $user_id )->user_email;
        return my_platform_api_update_tier( $email, $new_tier );
    }

    public function onEpisodePublished( int $episode_id, int $show_id ): void {
        if ( ! $this->isConfigured() ) { return; }
        my_platform_api_post_announcement( get_the_title( $episode_id ) );
    }
}

// Registration. Keyed by platform slug; the value is your instance.
add_filter( 'benecaster_community_platforms', function ( array $platforms ): array {
    $platforms['my-platform'] = new MyPlatform();

    return $platforms;
} );

View on GitHub →

Hooks Used

  • benecaster_community_platforms

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