BP_Friends_Friendship::populate()
Set up data about the current friendship.
Description
Source
File: bp-friends/classes/class-bp-friends-friendship.php
public function populate() {
global $wpdb;
$bp = buddypress();
// Check cache for friendship data.
$friendship = wp_cache_get( $this->id, 'bp_friends_friendships' );
// Cache missed, so query the DB.
if ( false === $friendship ) {
$friendship = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) );
wp_cache_set( $this->id, $friendship, 'bp_friends_friendships' );
}
// No friendship found so set the ID and bail.
if ( empty( $friendship ) || is_wp_error( $friendship ) ) {
$this->id = 0;
return;
}
$this->initiator_user_id = (int) $friendship->initiator_user_id;
$this->friend_user_id = (int) $friendship->friend_user_id;
$this->is_confirmed = (int) $friendship->is_confirmed;
$this->is_limited = (int) $friendship->is_limited;
$this->date_created = $friendship->date_created;
if ( ! empty( $this->populate_friend_details ) ) {
if ( $this->friend_user_id == bp_displayed_user_id() ) {
$this->friend = new BP_Core_User( $this->initiator_user_id );
} else {
$this->friend = new BP_Core_User( $this->friend_user_id );
}
}
}
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.