BP_Core_Notification::save()
Update or insert notification details into the database.
Description
Return
(bool) Success or failure.
Source
File: bp-core/classes/class-bp-core-notification.php
public function save() { global $wpdb; $bp = buddypress(); // Update. if ( !empty( $this->id ) ) { $sql = $wpdb->prepare( "UPDATE {$bp->core->table_name_notifications} SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = %s, is_new = %d ) WHERE id = %d", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id ); // Save. } else { $sql = $wpdb->prepare( "INSERT INTO {$bp->core->table_name_notifications} ( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, %s, %d )", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new ); } if ( !$result = $wpdb->query( $sql ) ) return false; $this->id = $wpdb->insert_id; return true; }
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.