This function has been deprecated. BuddyBoss 1.2.8 instead.
bp_activity_get_userid_from_mentionname( string $mentionname )
Get a user ID from a “mentionname”, the name used for a user in @-mentions.
Description
Parameters
- $mentionname
-
(Required) Username of user in @-mentions.
Return
(int|bool) ID of the user, if one is found. Otherwise false.
Source
File: bp-activity/bp-activity-functions.php
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | function bp_activity_get_userid_from_mentionname( $mentionname ) { $user_id = false; /* * In username compatibility mode, hyphens are ambiguous between * actual hyphens and converted spaces. * * @todo There is the potential for username clashes between 'foo bar' * and 'foo-bar' in compatibility mode. Come up with a system for * unique mentionnames. */ if ( bp_is_username_compatibility_mode() ) { // First, try the raw username. $userdata = get_user_by( 'login' , $mentionname ); // Doing a direct query to use proper regex. Necessary to // account for hyphens + spaces in the same user_login. if ( empty ( $userdata ) || ! is_a ( $userdata , 'WP_User' ) ) { global $wpdb ; $regex = esc_sql( str_replace ( '-' , '[ \-]' , $mentionname ) ); $user_id = $wpdb ->get_var( "SELECT ID FROM {$wpdb->users} WHERE user_login REGEXP '{$regex}'" ); } else { $user_id = $userdata ->ID; } // When username compatibility mode is disabled, the mentionname is // the same as the nicename. } else { $user_id = bp_core_get_userid_from_nickname( $mentionname ); } return $user_id ; } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.2.8 | BuddyBoss 1.2.8 |
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.