BP_Core_Notification::delete_for_user_by_item_id( int $user_id, int $item_id, string $component_name, string $component_action, int|bool $secondary_item_id = false )
Delete all the notifications that have a specific item id, component name and action.
Description
Parameters
- $user_id
-
(int) (Required) The ID of the user who the notifications are for.
- $item_id
-
(int) (Required) The item ID of the notifications we wish to delete.
- $component_name
-
(string) (Required) The name of the component that the notifications we wish to delete.
- $component_action
-
(string) (Required) The action of the component that the notifications we wish to delete.
- $secondary_item_id
-
(int|bool) (Optional) (optional) The secondary item id of the notifications that we wish to use to delete.
Default value: false
Return
(mixed)
Source
File: bp-core/classes/class-bp-core-notification.php
public static function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false ) { global $wpdb; $bp = buddypress(); $secondary_item_sql = !empty( $secondary_item_id ) ? $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id ) : ''; return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND item_id = %d AND component_name = %s AND component_action = %s{$secondary_item_sql}", $user_id, $item_id, $component_name, $component_action ) ); }
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.