Add the New BuddyPress Mentions Interface to bbPress Forum Replies

BuddyPress 2.1 was released yesterday with a handy new mentions interface that pops up a suggestions panel as you are typing. In the past, you would need to know a member’s username in order to write a mention in the activity stream, which many times meant looking it up. The new mentions interface makes it easier to pull users into conversations that happen in the activity stream.

Many BuddyPress sites utilize bbPress for forums, as the plugins work quite seamlessly together. bbPress forum replies is another place where access to the new mentions interface would prove to be enormously useful, as forums are a central place for interaction and conversation on many community sites. A ticket for adding this already exists in bbPress trac.

In the meantime, BuddyPress core developer Mathieu Viet, better known as @imath, posted a quick gist for adding the mentions to bbPress forum replies. Simply add the code to your bp-custom.php file:

[php]<?php
function custom_bbpress_maybe_load_mentions_scripts( $retval = false ) {
if ( function_exists( ‘bbpress’ ) && is_bbpress() ) {
$retval = true;
}

return $retval;
}
add_filter( ‘bp_activity_maybe_load_mentions_scripts’, ‘custom_bbpress_maybe_load_mentions_scripts’ );[/php]

I tested it and it works exactly the same as it would in the activity stream. Here’s what it looks like, added to a test site with BuddyPress and bbPress:

Keep an eye on the relevant ticket, as this feature is likely to make its way into bbPress core in the near future. In the meantime, many thanks to @imath for this quick workaround. You can add it to any site using BuddyPress 2.1 and bbPress for better use of mentions in your forums.