BP_Notifications_Notification::mark_all_for_user( int $user_id, int $is_new, int $item_id, string $component_name = '', string $component_action = '', int $secondary_item_id )
Mark all user notifications as read.
Description Description
Parameters Parameters
- $user_id
-
(Required) The ID of the user who the notifications are for.
- $is_new
-
(Required) Mark as read (1) or unread (0).
- $item_id
-
(Required) Item ID being acted on.
- $component_name
-
(Optional) Name of component the notifications are for.
Default value: ''
- $component_action
-
(Optional) Name of the component action.
Default value: ''
- $secondary_item_id
-
(Required) The ID of the secondary item.
Return Return
(int|false) False on failure to update. ID on success.
Source Source
File: bp-notifications/classes/class-bp-notifications-notification.php
public static function mark_all_for_user( $user_id, $is_new = 0, $item_id = 0, $component_name = '', $component_action = '', $secondary_item_id = 0 ) {
// Values to be updated.
$update_args = array(
'is_new' => $is_new,
);
// WHERE clauses.
$where_args = array(
'user_id' => $user_id,
);
if ( ! empty( $item_id ) ) {
$where_args['item_id'] = $item_id;
}
if ( ! empty( $component_name ) ) {
$where_args['component_name'] = $component_name;
}
if ( ! empty( $component_action ) ) {
$where_args['component_action'] = $component_action;
}
if ( ! empty( $secondary_item_id ) ) {
$where_args['secondary_item_id'] = $secondary_item_id;
}
return self::update( $update_args, $where_args );
}
Changelog Changelog
| Version | Description |
|---|---|
| 1.9.0 | Introduced. |