bp_activity_get_user_mentionname( int|string $user_id )

Determine a user’s “mentionname”, the name used for that user in @-mentions.

Description

Parameters

$user_id

(Required) ID of the user to get @-mention name for.

Return

(string) $mentionname User name appropriate for @-mentions.

Source

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

function bp_activity_get_user_mentionname( $user_id ) {
	$mentionname = '';

	$userdata = bp_core_get_core_userdata( $user_id );

	if ( $userdata ) {
		if ( bp_is_username_compatibility_mode() ) {
			$mentionname = str_replace( ' ', '-', $userdata->user_login );
		} else {
			$mentionname = get_user_meta( $userdata->ID, 'nickname', true );
		}
	}

	return $mentionname;
}

Changelog

Changelog
Version Description
BuddyPress 1.9.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.