bbp_get_topic_subscribers( int $topic_id )
Get the users who have subscribed to the topic
Description
Parameters
- $topic_id
-
(Optional) Topic id
Return
(array|bool) Results if the topic has any subscribers, otherwise false
Source
File: bp-forums/users/functions.php
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | function bbp_get_topic_subscribers( $topic_id = 0 ) { $topic_id = bbp_get_topic_id( $topic_id ); if ( empty ( $topic_id ) ) return ; global $wpdb ; $key = $wpdb ->prefix . '_bbp_subscriptions' ; $users = wp_cache_get( 'bbp_get_topic_subscribers_' . $topic_id , 'bbpress_users' ); if ( false === $users ) { $users = $wpdb ->get_col( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = '{$key}' and FIND_IN_SET('{$topic_id}', meta_value) > 0" ); wp_cache_set( 'bbp_get_topic_subscribers_' . $topic_id , $users , 'bbpress_users' ); } return apply_filters( 'bbp_get_topic_subscribers' , $users ); } |
Changelog
Version | Description |
---|---|
bbPress (r2668) | 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.