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.
Source Source
File: bp-xprofile/classes/class-bp-xprofile-profiledata.php
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | 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 ; } } |
Changelog Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |