Skip to main content

benecaster_member_thanks_query_types

Filter Premium

Filters the registered query strategies available to the [benecaster_member_thanks] shortcode and — when the Podcast Workflow add-on is active — to the Member Thanks tile in the Episode Workbench. The array is keyed by type slug; each value is a plain array with a label, a description and a results callable. There is no interface to implement and no class name to know.

label is the display name in the selector dropdown and description is the helper text below it. results receives ( int $show_id, int $episode_id, array $args ) and returns a list of rows carrying at least user_id, display_name, tier_slug and joined_at (anniversary_label optional). Honour count and tier_slug from $args when they are set. Built-in type slugs are new_since_last_episode, random, random_cycling and milestone.

Parameters

Name Type Default Description
$types array Keyed array of strategy definitions: slug => [ 'label' => string, 'description' => string, 'results' => callable ].

Returns: array

Example

add_filter( 'benecaster_member_thanks_query_types', function ( array $types ): array {
    $types['top_supporters'] = [
        'label'       => __( 'Top supporters', 'my-addon' ),
        'description' => __( 'Members with the highest lifetime support.', 'my-addon' ),
        'results'     => function ( int $show_id, int $episode_id, array $args ): array {
            return my_get_top_supporters(
                $show_id,
                $args['count'] ?? 5,
                $args['tier_slug'] ?? null
            );
        },
    ];

    return $types;
} );

Notes

Custom types added via this filter appear automatically in the Episode Workbench tile's query selector dropdown — no Workbench code changes are needed. Do not reuse a built-in slug (new_since_last_episode, random, random_cycling, milestone) as your own key.

results receives ( int $show_id, int $episode_id, array $args )show first. The sibling filter benecaster_related_episodes_query_types takes the same two IDs in the opposite order, and both are integers, so PHP will not catch a transposition.

An entry whose results is missing or not callable is silently discarded, not fataled — a type that never appears in the dropdown is usually a malformed definition rather than a registration failure.

random and random_cycling are deliberately separate strategies, not a duplicate. random is a plain random draw with no memory; random_cycling (Podcast Workflow add-on) works through the whole subscriber list before anyone repeats. Without that add-on, random_cycling behaves like random — the separate slug exists so a podcaster can state which they meant, rather than having the meaning change when an add-on is activated.

Affects

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