Skip to main content

benecaster_follower_signup_output

Filter Premium Since v1.0.0

Filters the rendered HTML output of the [benecaster_follower_signup] shortcode before it is returned to the page. The $state parameter identifies the current render state: 'form' for the initial page load or after a validation failure, 'success' after a successful signup, and 'error' after a server-side failure. Use to wrap the markup in a custom container, inject analytics data attributes, or replace the success state with fully branded HTML.

Note that the 'success' state also fires for returning followers (duplicate signups). Benecaster intentionally does not distinguish new from returning followers in the rendered output to prevent email enumeration.

Parameters

Name Type Default Description
$html string Full rendered shortcode HTML
$show_id int ID of the show
$atts array Resolved shortcode attributes
$state string Current render state: 'form', 'success', or 'error'

Returns: string

Examples

Add analytics data attribute to container

add_filter( 'benecaster_follower_signup_output', function( $html, $show_id, $atts, $state ) {
    $html = str_replace( '<div class="bc-follower-signup"', '<div class="bc-follower-signup" data-state="' . esc_attr( $state ) . '"', $html );
    return $html;
}, 10, 4 );

Wrap output in custom container

add_filter(
    'benecaster_follower_signup_output',
    function ( string $html, int $show_id, array $atts, string $state ): string {
        return '<div class="my-signup-wrapper" data-state="' . esc_attr( $state ) . '">' . $html . '</div>';
    },
    10, 4
);

Replace success state with branded HTML

add_filter(
    'benecaster_follower_signup_output',
    function ( string $html, int $show_id, array $atts, string $state ): string {
        if ( 'success' !== $state ) {
            return $html;
        }
        return '<div class="follower-welcome"><h2>' . esc_html__( 'Welcome!', 'my-theme' ) . '</h2><p>' . esc_html__( 'Check your inbox for your feed URL.', 'my-theme' ) . '</p></div>';
    },
    10, 4
);

Notes

The 'success' state fires for both new and returning followers. Benecaster does not surface duplicate signups to the visitor in order to prevent email enumeration — your callback cannot distinguish a first-time signup from a returning one using $state alone.

Affects

  • [benecaster_follower_signup](/shortcodes/benecaster-follower-signup/) shortcode