BP_REST_Messages_Actions_Endpoint::rest_hide_thread( integer $thread_id, boolen $value )

Hide unhide message thread based on the logged in user.

Description

Parameters

$thread_id

(Required) ID of the Messages Thread.

$value

(Required) Action value.

Return

(bool|void)

Source

File: bp-messages/classes/class-bp-rest-messages-actions-endpoint.php

237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
protected function rest_hide_thread( $thread_id, $value ) {
    global $bp, $wpdb;
 
    if ( empty( $value ) ) {
        // phpcs:ignore
        $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_hidden = %d WHERE thread_id = %d AND user_id = %d", 0, (int) $thread_id, bp_loggedin_user_id() ) );
        return true;
    } elseif ( ! empty( $value ) ) {
        // phpcs:ignore
        $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_hidden = %d WHERE thread_id = %d AND user_id = %d", 1, (int) $thread_id, bp_loggedin_user_id() ) );
        return true;
    }
 
    return false;
}

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.