benecaster_reference_groups
Filters the reference group list for a show before it is included in the show REST response. This filter fires on every full show response. Use to inject synthetic groups managed outside the database, reorder existing groups, or remove groups programmatically.
Groups returned from this filter must include `id`, `name`, and `display_order` keys. References whose `group_id` does not match any returned group render under the ungrouped fallback heading in the episode editor. This filter fires on read, not on write — it does not affect what is stored in the database.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$groups |
array |
— | Array of reference group objects {id, name, display_order} |
$show_id |
int |
— | ID of the show |
Returns:
array
Examples
Inject synthetic Sponsored Links group
add_filter( 'benecaster_reference_groups', function ( $groups, $show_id ) {
$sponsored = get_post_meta( $show_id, '_sponsored_reference_group', true );
if ( $sponsored ) {
array_unshift( $groups, [
'id' => 'synthetic-sponsored',
'name' => 'Sponsored Links',
'display_order' => -1,
] );
}
return $groups;
}, 10, 2 );
Inject group conditionally when add-on is active
add_filter( 'benecaster_reference_groups', function ( array $groups, int $show_id ): array {
if ( ! my_addon_is_active_for_show( $show_id ) ) {
return $groups;
}
array_unshift( $groups, [
'id' => 'my_addon_sponsored',
'name' => 'Sponsored Links',
'display_order' => -1,
] );
return $groups;
}, 10, 2 );
Notes
Use a string-based or negative id value for synthetic groups to avoid collisions with real database IDs. Pair with benecaster_episode_references to assign references to the injected group.