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

1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
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.