xprofile_get_random_profile_data( int $user_id, bool $exclude_fullname = true )

Fetches a random piece of profile data for the user.

Description

Parameters

$user_id

(Required) User ID of the user to get random data for.

$exclude_fullname

(Optional) whether or not to exclude the full name field as random data. Defaults to true.

Default value: true

Return

(string|bool) The fetched random data for the user, or false if no data or no match.

Source

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

function xprofile_get_random_profile_data( $user_id, $exclude_fullname = true ) {
	$field_data = BP_XProfile_ProfileData::get_random( $user_id, $exclude_fullname );

	if ( empty( $field_data ) ) {
		return false;
	}

	$field_data[0]->value = xprofile_format_profile_field( $field_data[0]->type, $field_data[0]->value );

	if ( empty( $field_data[0]->value ) ) {
		return false;
	}

	/**
	 * Filters a random piece of profile data for the user.
	 *
	 * @since BuddyPress 1.0.0
	 *
	 * @param array $field_data Array holding random profile data.
	 */
	return apply_filters( 'xprofile_get_random_profile_data', $field_data );
}

Changelog

Changelog
Version Description
BuddyPress 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.