Closed devhaozi closed 1 year ago
I use WordPress multisite and only activate bbPress on one site. When I use this plugin, The sites without activate bbPress will throw a PHP error bbp_get_topic_id function not exist around file class-bbpress.php line 492.
I suggest adding a judge to fix this:
if ( ! function_exists( 'bbp_get_topic_id' ) ) { return []; }
The modified complete function is as follows:
public function get_topic_users( $topic_id = 0 ) { if ( ! function_exists( 'bbp_get_topic_id' ) ) { return []; } $topic_id = bbp_get_topic_id( $topic_id ); if ( empty( $topic_id ) ) { return []; } $user_id = bbp_get_topic_author_id( $topic_id ); $users = [ $user_id ]; $users_formatted = [ $this->get_user_data( $user_id, $topic_id ) ]; // Get an array of replies for the topic $replies = get_posts( [ 'fields' => 'ids', 'numberposts' => 100, 'post_parent' => $topic_id, 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), ] ); // Loop through the replies and get the user IDs foreach ( $replies as $reply_id ) { $user_id = bbp_get_reply_author_id( $reply_id ); // Add the user ID to the array if it's not already there if ( ! in_array( $user_id, $users ) ) { $users[] = $user_id; $users_formatted[] = $this->get_user_data( $user_id, $reply_id ); } } return $users_formatted; }
I use WordPress multisite and only activate bbPress on one site. When I use this plugin, The sites without activate bbPress will throw a PHP error bbp_get_topic_id function not exist around file class-bbpress.php line 492.
I suggest adding a judge to fix this:
The modified complete function is as follows: