| @@ -563,13 +563,15 @@ | ||
| 563 | 563 | if ( isset( $topic['status'] ) && (int) $topic['status'] !== 0 ) { |
| 564 | 564 | return new \WP_Error( 'unapproved_topic', wpforo_phrase( 'Unapproved topics cannot be indexed', false ) ); |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - // Get all posts for this topic ordered by creation date | |
| 567 | + // Get all approved posts for this topic ordered by creation date | |
| 568 | + // Only index approved posts (status=0) to prevent unapproved content from appearing in search | |
| 568 | 569 | $posts = WPF()->post->get_posts( [ |
| 569 | 570 | 'topicid' => $topicid, |
| 570 | 571 | 'orderby' => 'created', |
| 571 | 572 | 'order' => 'ASC', |
| 573 | + 'status' => 0, | |
| 572 | 574 | ] ); |
| 573 | 575 | if ( empty( $posts ) ) { |
| 574 | 576 | return new \WP_Error( 'no_posts', wpforo_phrase( 'No posts found for topic', false ) ); |
| 575 | 577 | } |
| @@ -826,12 +828,14 @@ | ||
| 826 | 828 | } |
| 827 | 829 | |
| 828 | 830 | // Bypass user permission check - this is admin-initiated backend indexing. |
| 829 | 831 | // Private/unapproved topics are already filtered above. |
| 832 | + // Only index approved posts (status=0) to prevent unapproved content from appearing in search. | |
| 830 | 833 | $posts = WPF()->post->get_posts( [ |
| 831 | 834 | 'topicid' => $topicid, |
| 832 | 835 | 'orderby' => 'created', |
| 833 | 836 | 'order' => 'ASC', |
| 837 | + 'status' => 0, | |
| 834 | 838 | 'check_private' => false, |
| 835 | 839 | ] ); |
| 836 | 840 | |
| 837 | 841 | if ( empty( $posts ) ) { |