BP_Activity_Activity::populate()
Populate the object with data about the specific activity item.
Description
Source
File: bp-activity/classes/class-bp-activity-activity.php
public function populate() {
global $wpdb;
$row = wp_cache_get( $this->id, 'bp_activity' );
if ( false === $row ) {
$bp = buddypress();
$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) );
wp_cache_set( $this->id, $row, 'bp_activity' );
}
if ( empty( $row ) ) {
$this->id = 0;
return;
}
$this->id = (int) $row->id;
$this->item_id = (int) $row->item_id;
$this->secondary_item_id = (int) $row->secondary_item_id;
$this->user_id = (int) $row->user_id;
$this->primary_link = $row->primary_link;
$this->component = $row->component;
$this->type = $row->type;
$this->action = $row->action;
$this->content = $row->content;
$this->date_recorded = $row->date_recorded;
$this->hide_sitewide = (int) $row->hide_sitewide;
$this->mptt_left = (int) $row->mptt_left;
$this->mptt_right = (int) $row->mptt_right;
$this->is_spam = (int) $row->is_spam;
$this->privacy = $row->privacy;
// Generate dynamic 'action' when possible.
$action = bp_activity_generate_action_string( $this );
if ( false !== $action ) {
$this->action = $action;
// If no callback is available, use the literal string from
// the database row.
} elseif ( ! empty( $row->action ) ) {
$this->action = $row->action;
// Provide a fallback to avoid PHP notices.
} else {
$this->action = '';
}
}
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.