Halloween Sale 15% off Ends in See the plans
PHP

bbPress: "Topic Starter" Badge on Replies

Adds a small "Topic starter" badge under the author's name on replies written by the person who opened the topic, making long threads easier to follow.

Don’t have WPIDE yet? Install it on your site

Code

if ( ! function_exists( 'bbp_get_reply_author_id' ) ) {
    return;
}

add_action( 'bbp_theme_after_reply_author_details', function () {
    $reply_id  = (int) bbp_get_reply_id();
    $topic_id  = (int) bbp_get_reply_topic_id( $reply_id );
    $author_id = (int) bbp_get_reply_author_id( $reply_id );

    // The opening post itself is the topic, so only mark later replies.
    if ( ! $author_id || $reply_id === $topic_id || $author_id !== (int) bbp_get_topic_author_id( $topic_id ) ) {
        return;
    }

    echo '<span class="wpide-bbp-starter" style="display:inline-block;margin-top:.3em;padding:0 .5em;border-radius:999px;border:1px solid currentColor;font-size:.75em">Topic starter</span>';
} );

Notes

Style the badge with the .wpide-bbp-starter class.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.