BP_XProfile_ProfileData::get_fielddataid_byid( int $field_id, int $user_id )

Get the user’s field data id by the id of the xprofile field.


Parameters Parameters

$field_id

(int) (Required) Field ID being queried for.

$user_id

(int) (Required) User ID associated with field.


Top ↑

Return Return

(int) $fielddata_id


Source Source

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

	public static function get_fielddataid_byid( $field_id, $user_id ) {
		global $wpdb;

		if ( empty( $field_id ) || empty( $user_id ) ) {
			$fielddata_id = 0;
		} else {
			$bp = buddypress();

			// Check cache first.
			$cache_key = "{$user_id}:{$field_id}";
			$fielddata = wp_cache_get( $cache_key, 'bp_xprofile_data' );
			if ( false === $fielddata || empty( $fielddata->id ) ) {
				$fielddata_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $field_id, $user_id ) );
			} else {
				$fielddata_id = $fielddata->id;
			}
		}

		return (int) $fielddata_id;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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