BP_Activity_Follow::save()
Saves a follow relationship to the database.
Description
Source
File: bp-activity/classes/class-bp-activity-follow.php
public function save() { global $wpdb, $bp; // do not use these filters // use the 'bp_follow_before_save' hook instead $this->leader_id = apply_filters( 'bp_follow_leader_id_before_save', $this->leader_id, $this->id ); $this->follower_id = apply_filters( 'bp_follow_follower_id_before_save', $this->follower_id, $this->id ); /** * @todo add title/description * * @since BuddyBoss 1.0.0 */ do_action_ref_array( 'bp_follow_before_save', array( &$this ) ); // leader ID is required // this allows plugins to bail out of saving a follow relationship // use hooks above to redeclare 'leader_id' so it is empty if you need to bail if ( empty( $this->leader_id ) ) { return false; } // update existing entry if ( $this->id ) { $result = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->activity->table_name_follow} SET leader_id = %d, follower_id = %d WHERE id = %d", $this->leader_id, $this->follower_id, $this->id ) ); // add new entry } else { $result = $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->activity->table_name_follow} ( leader_id, follower_id ) VALUES ( %d, %d )", $this->leader_id, $this->follower_id ) ); $this->id = $wpdb->insert_id; } /** * @todo add title/description * * @since BuddyBoss 1.0.0 */ do_action_ref_array( 'bp_follow_after_save', array( &$this ) ); return $result; }
Changelog
Version | Description |
---|---|
BuddyBoss 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.