BP_XProfile_ProfileData::get_random( int $user_id, string $exclude_fullname )

Get random field type by user ID.

Description

Parameters

$user_id

(int) (Required) User ID to query for.

$exclude_fullname

(string) (Required) SQL portion used to exclude by field ID.

Return

(array|null|object)

Source

File: bp-xprofile/classes/class-bp-xprofile-profiledata.php

	public static function get_random( $user_id, $exclude_fullname ) {
		global $wpdb;

		$exclude_sql = ! empty( $exclude_fullname ) ? ' AND pf.id != 1' : '';

		$bp = buddypress();

		return $wpdb->get_results( $wpdb->prepare( "SELECT pf.type, pf.name, pd.value FROM {$bp->profile->table_name_data} pd INNER JOIN {$bp->profile->table_name_fields} pf ON pd.field_id = pf.id AND pd.user_id = %d {$exclude_sql} ORDER BY RAND() LIMIT 1", $user_id ) );
	}

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.