bp_nouveau_ajax_hide_thread()

Description

Source

File: bp-templates/bp-nouveau/includes/messages/ajax.php

2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
function bp_nouveau_ajax_hide_thread() {
 
    global $bp, $wpdb;
 
    $response = array(
        'feedback' => __( 'There was a problem deleting your messages. Please try again.', 'buddyboss' ),
        'type'     => 'error',
    );
 
    if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'bp_nouveau_messages' ) ) {
        wp_send_json_error( $response );
    }
 
    if ( empty( $_POST['id'] ) ) {
        wp_send_json_error( $response );
    }
 
    $thread_ids = wp_parse_id_list( $_POST['id'] );
 
    foreach ( $thread_ids as $thread_id ) {
        $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() ) );
    }
 
    wp_send_json_success(
        array(
            'type'     => 'success',
            'messages' => 'Thread removed successfully.',
        )
    );
}

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.