Perform a community action on episode publish
When benecaster_episode_published fires, the Community Integrations add-on queues onEpisodePublished() for every registered platform configured for that show, once per episode, and runs it after the save, so the episode’s meta is there to read. Implement this method to create a discussion thread, post an announcement, pin a notification, or update a community calendar. The Circle built-in implementation — shown in the code — is the canonical example: it reads the episode’s own choice, falls back to the show’s setting, creates a Circle post, and stores the URL as a merge tag.
Code
<?php
// Circle's built-in onEpisodePublished() — canonical example.
public function onEpisodePublished( int $episode_id, int $show_id ): void {
// 'default' → follow the show's setting, 'create' → always, 'skip' → never.
$mode = get_post_meta( $episode_id, '_benecaster_circle_discussion_mode', true ) ?: 'default';
$show_wants = (bool) get_post_meta( $show_id, '_benecaster_circle_auto_discussion', true );
if ( $mode === 'skip' || ( $mode === 'default' && ! $show_wants ) ) { return; }
$space_id = get_post_meta( $episode_id, '_benecaster_circle_discussion_space', true )
?: get_post_meta( $show_id, '_benecaster_circle_discussion_space', true );
if ( ! $space_id ) { return; }
$post_url = $this->client( $show_id )->createPost( // the show's own Circle credentials
$space_id,
// get_the_title() returns HTML (Dave’s Q&A); this is plain text.
html_entity_decode( get_the_title( $episode_id ), ENT_QUOTES, 'UTF-8' ),
get_post_meta( $episode_id, '_benecaster_description_rss', true )
);
if ( $post_url ) {
update_post_meta( $episode_id, '_benecaster_circle_discussion_url', $post_url );
}
}
Hooks Used
Need this built rather than just documented? See our services →