Hooks & Filters Reference

Get Started

Customize BuddyPress Hashtags behavior using WordPress hooks and filters.

Action Hooks

buddypress_hashtag_inserted

Fired after a hashtag is recorded in the database.

add_action( 'buddypress_hashtag_inserted', 'my_hashtag_handler', 10, 2 );

function my_hashtag_handler( $ht_name, $ht_type ) {
    // Custom processing after hashtag insertion
    error_log( "Hashtag saved: {$ht_name} ({$ht_type})" );
}

Parameters:

  • $ht_name (string) – The hashtag without #
  • $ht_type (string) – Content type (‘buddypress’, ‘bbpress’, ‘post’, ‘page’)

Filter Hooks

Widget Filters

bpht_bp_hashtag_widget_instance – Customize BuddyPress hashtag widget instance before display.

add_filter( 'bpht_bp_hashtag_widget_instance', 'customize_widget_settings' );

function customize_widget_settings( $instance ) {
    $instance['limit'] = 30;
    return $instance;
}

Query Filters

wbcom_hashtag_widget_query – Customize hashtag database queries for widgets.

add_filter( 'wbcom_hashtag_widget_query', 'custom_hashtag_query', 10, 3 );

function custom_hashtag_query( $sql, $type, $limit ) {
    global $wpdb;
    $table_name = $wpdb->prefix . 'bpht_hashtags';

    // Only show hashtags with more than 5 uses
    return $wpdb->prepare(
        "SELECT * FROM {$table_name}
         WHERE ht_type = %s AND ht_count > 5
         ORDER BY ht_count DESC LIMIT %d",
        $type,
        $limit
    );
}

wbcom_hashtag_widget_array_hashtags – Filter the final hashtags array before widget display.

add_filter( 'wbcom_hashtag_widget_array_hashtags', 'filter_widget_hashtags', 10, 3 );

function filter_widget_hashtags( $hashtags, $type, $limit ) {
    // Remove specific hashtags from widget display
    foreach ( $hashtags as $name => $data ) {
        if ( $name === 'hidden_tag' ) {
            unset( $hashtags[ $name ] );
        }
    }
    return $hashtags;
}

Display Filters

bpht_alpha_numeric_hashtags_enabled – Override alphanumeric hashtag settings programmatically.

add_filter( 'bpht_alpha_numeric_hashtags_enabled', function( $enabled ) {
    // Force enable for administrators
    if ( current_user_can( 'administrator' ) ) {
        return true;
    }
    return $enabled;
} );

bpht_hashtag_url – Modify the URL for hashtag links.

add_filter( 'bpht_hashtag_url', 'custom_hashtag_url', 10, 2 );

function custom_hashtag_url( $url, $hashtag ) {
    // Custom URL structure
    return home_url( '/hashtag/' . $hashtag );
}

Priority Reference

Priority Runs
1-10 Before hashtag processing
20-30 During hashtag processing (plugin uses 25)
40+ After hashtag processing

Common Customizations

Hide Specific Hashtags from Widgets

add_filter( 'wbcom_hashtag_widget_array_hashtags', function( $hashtags ) {
    $hidden = array( 'test', 'spam', 'admin' );
    foreach ( $hidden as $tag ) {
        unset( $hashtags[ $tag ] );
    }
    return $hashtags;
} );

Log All New Hashtags

add_action( 'buddypress_hashtag_inserted', function( $name, $type ) {
    error_log( sprintf( 'New hashtag: #%s (type: %s)', $name, $type ) );
}, 10, 2 );
Last updated: January 29, 2026