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

Get random field type by user ID.

Parameters Parameters


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


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

Top ↑

Return Return


Source 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 ) );

Top ↑

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.