BP_Notifications_Notification::mark_all_from_user( int $user_id, int $is_new, string $component_name = '', string $component_action = '', int $secondary_item_id )

Mark all notifications from a user as read.

Description

Parameters

$user_id

(Required) The ID of the user who the notifications are from.

$is_new

(Required) Mark as read (1) or unread (0).

$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

(int|false)

Source

File: bp-notifications/classes/class-bp-notifications-notification.php

1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
public static function mark_all_from_user( $user_id, $is_new = 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(
        'item_id' => $user_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
BuddyPress 1.9.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.