bp_media_get_thread_id( $media_id )

Description

Source

File: bp-media/bp-media-functions.php

2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
function bp_media_get_thread_id( $media_id ) {
 
    $thread_id = 0;
 
    if ( bp_is_active( 'messages' ) ) {
        $meta = array(
            array(
                'key'     => 'bp_media_ids',
                'value'   => $media_id,
                'compare' => 'LIKE',
            ),
        );
 
        // Check if there is already previously individual group thread created.
        if ( bp_has_message_threads( array( 'meta_query' => $meta ) ) ) { // phpcs:ignore
            while ( bp_message_threads() ) {
                bp_message_thread();
                $thread_id = bp_get_message_thread_id();
                if ( $thread_id ) {
                    break;
                }
            }
        }
    }
    return apply_filters( 'bp_media_get_thread_id', $thread_id, $media_id );
 
}

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.