bp_core_get_user_displaynames( array $user_ids )

Fetch the display name for a group of users.


Description Description

Uses the ‘Name’ field in xprofile if available. Falls back on WP display_name, and then user_nicename.


Top ↑

Parameters Parameters

$user_ids

(array) (Required) Array of user IDs to get display names for.


Top ↑

Return Return

(array) Associative array of the format "id" => "displayname".


Source Source

File: bp-members/bp-members-functions.php

function bp_core_get_user_displaynames( $user_ids ) {

	// Sanitize.
	$user_ids = wp_parse_id_list( $user_ids );

	// Remove dupes and empties.
	$user_ids = array_unique( array_filter( $user_ids ) );

	if ( empty( $user_ids ) ) {
		return array();
	}

	// Warm the WP users cache with a targeted bulk update.
	cache_users( $user_ids );

	$retval = array();
	foreach ( $user_ids as $user_id ) {
		$retval[ $user_id ] = bp_core_get_user_displayname( $user_id );
	}

	return $retval;
}


Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.