Skip to main content

benecaster_managed_email_types

Filter Free

Filters the array of registered email types available across the plugin. Every type returned by this filter appears as an editable template in the Email Editor add-on’s template manager. Core registers its own types unconditionally at boot, in EmailTypeRegistry::core_types() — the billing-lifecycle types among them are registered whether or not the built-in membership feature is active. Add-ons register their own types by hooking this filter at plugin boot.

This is a descriptive catalogue and nothing more. It carries a type, a label, a description and an add-on slug — no subject, no template path — so there is no registry for a sender to look those up in, and every call site supplies its own pair. Registering a type does not by itself route, gate, suppress or template an email: sending goes through benecaster_send_email() / EmailManager, and opt-out protection is benecaster_transactional_email_types. Registering is what makes the type editable and discoverable; it is not what makes it work.

Each type definition is an associative array with four required keys: type (a stable snake_case identifier unique across all plugins), label (human-readable name shown in the Email Editor), description (one-sentence summary of when the email is sent), and add_on (the registering add-on’s slug, or null for Benecaster types). The type string becomes part of type-specific hook names — keep it stable after release.

Parameters

Name Type Default Description
$types array Ordered array of type definition arrays: {type: string, label: string, description: string, add_on: string|null}

Returns: array

Examples

Register weekly digest email type

add_filter( 'benecaster_managed_email_types', function( $types ) {
    // Register a custom "weekly_digest" email type for an add-on.
    $types[] = [
        'type'        => 'weekly_digest',
        'label'       => 'Weekly Digest',
        'description' => 'A curated weekly roundup sent every Monday.',
        'add_on'      => 'my-digest-addon',
    ];
    return $types;
} );

Register type at plugin boot

add_action( 'benecaster_boot', function ( \Benecaster\Container $container ): void {
    add_filter( 'benecaster_managed_email_types', function ( array $types ): array {
        $types[] = [
            'type'        => 'my_episode_notification',
            'label'       => __( 'Episode Notification', 'my-addon' ),
            'description' => __( 'Sent to subscribers when a new episode becomes available for their tier.', 'my-addon' ),
            'add_on'      => 'my-addon',
        ];
        return $types;
    } );
} );

Notes

Register this filter at benecaster_boot, not init. The filter is read during plugin boot — registering on init or later may mean your type is absent when the Email Editor queries the list.

Do not reuse a type string core already holds — and read the list at runtime rather than from any page. apply_filters( 'benecaster_managed_email_types', [] ) returns core plus every active add-on, which is the only answer that stays correct as either changes; core's own set lives in EmailTypeRegistry::core_types(). A hand-copied list here would rot, and a collision is silent. token_revoked was named in this note and in the description as a core email type until 2026-09-02. There is no such email typebenecaster_token_revoked is an action that fires when a feed token is revoked, and the two are unrelated.

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