bp_core_fix_admin_bar_names( $wp_admin_bar )

Replace admin bar “Howdy” text Use proper display name and mention

Description

Source

File: bp-core/bp-core-adminbar.php

function bp_core_fix_admin_bar_names( $wp_admin_bar ) {
	$user_id      = get_current_user_id();
	$current_user = wp_get_current_user();

	if ( ! $user_id ) {
		return;
	}

	$avatar = get_avatar( $user_id, 26 );

	// my account
    $wp_admin_bar->add_node( [
        'id' => 'my-account',
        'title' => '<span class="display-name">' . bp_custom_display_name_format( $current_user->display_name, $user_id ) . $avatar . '</span>'
    ] );

	// user info
	$user_info  = get_avatar( $user_id, 64 );
	$user_info .= "<span class='display-name'>". bp_custom_display_name_format( $current_user->display_name, $user_id ) . "</span>";
	$user_info .= "<span class='username'>" . bp_activity_get_user_mentionname( $user_id ) . "</span>";

	$wp_admin_bar->add_menu([
		'id' => 'user-info',
		'title'  => $user_info
	]);
}

Changelog

Changelog
Version Description
BuddyBoss 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.