Skip to main content

benecaster_before_account

Action Free

Fires before the benecaster_account shortcode wrapper renders. This is the earliest hook point inside the account shortcode — it fires after authentication verification and before any output is generated, so the subscriber is confirmed logged-in when your callback runs.

This hook fires only when a logged-in subscriber is viewing their own account page. Output echoed here appears above all built-in account sections.

Parameters

Name Type Default Description
$user_id int WordPress user ID of the logged-in subscriber

Examples

Track account page views in analytics

add_action( 'benecaster_before_account', function( int $user_id ): void {
    // Queue an analytics event without echoing anything
    my_analytics_client()->track( 'account_page_viewed', [
        'user_id' => $user_id,
    ] );
} );

Inject custom banner above account

add_action( 'benecaster_before_account', function( int $user_id ): void {
    if ( get_user_meta( $user_id, 'my_addon_show_banner', true ) ) {
        echo '<div class="my-addon-banner">Special offer for you!</div>';
    }
} );

Affects

  • Subscriber Account Page

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