bbp_make_mentions_clickable_callback( array $matches = array() )

Callback to convert mention matchs to HTML A tag.

Description

Parameters

$matches

(array) (Optional) Single Regex Match.

Default value: array()

Return

(string) HTML A tag with link to user profile.

Source

File: bp-forums/common/formatting.php

function bbp_make_mentions_clickable_callback( $matches = array() ) {

	// Get user; bail if not found
	$user = get_user_by( 'slug', $matches[2] );
	if ( empty( $user ) || bbp_is_user_inactive( $user->ID ) ) {
		return $matches[0];
	}

	// Create the link to the user's profile
	$url    = bbp_get_user_profile_url( $user->ID );
	$anchor = '<a href="%1$s" rel="nofollow">@%2$s</a>';
	$link   = sprintf( $anchor, esc_url( $url ), esc_html( $user->user_nicename ) );

	return $matches[1] . $link;
}

Changelog

Changelog
Version Description
BuddyPress 2.6.0 Introduced.

Questions?

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.