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

Populates the XProfile profile data.


Description Description


Parameters Parameters

$field_id

(Required) Field ID to populate.

$user_id

(Required) User ID to populate for.


Top ↑

Source Source

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

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

		$cache_key   = "{$user_id}:{$field_id}";
		$profiledata = wp_cache_get( $cache_key, 'bp_xprofile_data' );

		if ( false === $profiledata ) {
			$bp = buddypress();

			$sql         = $wpdb->prepare( "SELECT * FROM {$bp->profile->table_name_data} WHERE field_id = %d AND user_id = %d", $field_id, $user_id );
			$profiledata = $wpdb->get_row( $sql );

			if ( $profiledata ) {
				wp_cache_set( $cache_key, $profiledata, 'bp_xprofile_data' );
			}
		}

		if ( $profiledata ) {
			$this->id           = (int) $profiledata->id;
			$this->user_id      = (int) $profiledata->user_id;
			$this->field_id     = (int) $profiledata->field_id;
			$this->value        = stripslashes( $profiledata->value );
			$this->last_updated = $profiledata->last_updated;

		} else {
			// When no row is found, we'll need to set these properties manually.
			$this->field_id	    = (int) $field_id;
			$this->user_id	    = (int) $user_id;
		}
	}

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.