This function has been deprecated. BuddyBoss 1.2.8 instead.

bp_activity_find_mention_by_at_sign( array $mentioned_users, string $content )

Locate usernames in an activity content string, as designated by an @ sign.




(array) (Required) Associative array with user IDs as keys and usernames as values.


(string) (Required) Activity content.


(array|bool) Associative array with user ID as key and username as value. Boolean false if no mentions found.


File: bp-activity/bp-activity-functions.php

function bp_activity_find_mention_by_at_sign( $mentioned_users, $content ) {
	$pattern = '/[@]+([A-Za-z0-9-_\.@]+)\b/';
	preg_match_all( $pattern, $content, $usernames );

	// Make sure there's only one instance of each username.
	$usernames = array_unique( $usernames[1] );

	// Bail if no usernames.
	if ( empty( $usernames ) ) {
		return $mentioned_users;

	// We've found some mentions! Check to see if users exist.
	foreach ( (array) array_values( $usernames ) as $username ) {
		$user_id = bp_activity_get_userid_from_mentionname( $username );

		// The user ID exists, so let's add it to our array.
		if ( ! empty( $user_id ) ) {
			$mentioned_users[ $user_id ] = $username;

	if ( empty( $mentioned_users ) ) {
		return $mentioned_users;

	return $mentioned_users;


Version Description
BuddyBoss 1.2.8 Introduced.


We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.