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

Fetches a random piece of profile data for the user.


Parameters Parameters

$user_id

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

$exclude_fullname

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

Default value: true


Top ↑

Return Return

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


Source 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 1.0.0
	 *
	 * @param array $field_data Array holding random profile data.
	 */
	return apply_filters( 'xprofile_get_random_profile_data', $field_data );
}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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