benecaster_field_groups
Filters the array of field group definitions before they are returned for a given custom post type. Fires when the episode editor (or any registered CPT editor) loads field values for display — not on the Field Group list screen.
Use to inject dynamically generated groups, reorder groups, or hide groups for specific CPTs. Synthetic groups with non-integer IDs are display-only: they appear in the editor with their injected fields, but write operations reject non-numeric field IDs and silently drop submitted values. To persist values from synthetic groups, add a dedicated REST endpoint from your add-on. Removing a group via this filter hides it from the editor UI but does not affect stored values.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$groups |
array |
— | Array of field group objects {id, name, cpt_slug, display_order, field_count, fields} |
$cpt_slug |
string |
— | The CPT being queried (e.g. 'benecaster_episode', 'benecaster_guest') |
Returns:
array
Examples
Inject synthetic read-only group for episodes
add_filter( 'benecaster_field_groups', function( $groups, $cpt_slug ) {
// Inject a synthetic "AI Summary" group for episodes only.
if ( 'benecaster_episode' === $cpt_slug ) {
$groups[] = [
'id' => 'synthetic-ai-summary',
'name' => 'AI Summary',
'cpt_slug' => $cpt_slug,
'display_order' => 99,
'field_count' => 1,
'fields' => [],
];
}
return $groups;
}, 10, 2 );
Add add-on field group when feature is active
add_filter( 'benecaster_field_groups', function ( array $groups, string $cpt_slug ): array {
if ( 'benecaster_episode' !== $cpt_slug || ! my_addon_feature_enabled() ) {
return $groups;
}
$groups[] = [
'id' => 'my_addon_dynamic_group',
'name' => 'Sponsor Information',
'cpt_slug' => 'benecaster_episode',
'display_order' => 99,
'fields' => [
[
'id' => 'my_addon_field_sponsor_name',
'group_id' => 'my_addon_dynamic_group',
'field_label' => 'Sponsor Name',
'field_key' => 'sponsor_name',
'field_type' => 'text',
'display_order' => 0,
'options' => null,
'required' => false,
],
],
];
return $groups;
}, 10, 2 );
Notes
This filter does not fire on the Field Group list screen — only when field values are being loaded for an object. Removing a group via this filter hides it from the editor UI but does not delete stored values; existing values remain in the database and are still returned by benecaster_get_field() and benecaster_get_fields(). Synthetic groups with non-integer IDs are display-only — write operations reject non-numeric field IDs and silently drop submitted values. This is a Free filter — it fires regardless of license status.