# bbPress: "Mark as Solved" for Support Topics

> Lets topic authors and moderators mark a topic as solved with one click; solved topics get a "[Solved]" label in their title so others find answers quickly.

- Type: PHP
- Runs: Run everywhere
- Category: [Users](https://wpide.com/library/category/users/)
- Tags: bbpress, support, topics
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/bbpress-mark-topic-solved/

## Code

```php
if ( ! function_exists( 'bbp_get_topic_id' ) ) {
    return;
}

add_action( 'bbp_template_before_single_topic', function () {
    $topic_id = (int) bbp_get_topic_id();

    if ( ! $topic_id || ! is_user_logged_in() ) {
        return;
    }

    if ( get_current_user_id() !== (int) bbp_get_topic_author_id( $topic_id ) && ! current_user_can( 'moderate', $topic_id ) ) {
        return;
    }

    $solved = (bool) get_post_meta( $topic_id, '_wpide_solved', true );
    $url    = wp_nonce_url( add_query_arg( array( 'wpide_solved' => $topic_id ), get_permalink( $topic_id ) ), 'wpide_solved_' . $topic_id );

    printf( '<p class="wpide-bbp-solved"><a class="button" href="%1$s">%2$s</a></p>', esc_url( $url ), esc_html( $solved ? 'Mark as unsolved' : 'Mark as solved' ) );
} );

add_action( 'template_redirect', function () {
    if ( empty( $_GET['wpide_solved'] ) || ! is_user_logged_in() ) {
        return;
    }

    $topic_id = absint( $_GET['wpide_solved'] );

    if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'wpide_solved_' . $topic_id ) ) {
        return;
    }

    if ( bbp_get_topic_post_type() !== get_post_type( $topic_id ) || ( get_current_user_id() !== (int) bbp_get_topic_author_id( $topic_id ) && ! current_user_can( 'moderate', $topic_id ) ) ) {
        return;
    }

    if ( get_post_meta( $topic_id, '_wpide_solved', true ) ) {
        delete_post_meta( $topic_id, '_wpide_solved' );
    } else {
        update_post_meta( $topic_id, '_wpide_solved', 1 );
    }

    wp_safe_redirect( get_permalink( $topic_id ) );
    exit;
} );

add_filter( 'bbp_get_topic_title', function ( $title, $topic_id ) {
    return get_post_meta( $topic_id, '_wpide_solved', true ) ? '[Solved] ' . $title : $title;
}, 10, 2 );
```

## Notes

The button appears above the topic for its author and moderators. Clicking again marks the topic as unsolved.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "bbPress: "Mark as Solved" for Support Topics" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
