get user id from username - buddyPress

Aspire Built

I need to get the id of the user by searching it on the input field. lets say i need an id of the user 'adre'(which is 33 actually). Any help would be appreciated.

// this way i can get username with user id.
$user_ID = 33;
$user = new BP_Core_User( $user_ID );
$user_array = $user->profile_data;
echo $user_nicename=$user_array['user_nicename']; // adre

// now i need to get user id by username.
//echo bp_displayed_user_id();
jayant

Try this get_userdatabylogin

$user = get_userdatabylogin('admin');
var_dump($user);
echo $user->ID; // prints the id of the user

or this

 <?php $user = get_user_by( $field, $value ); ?> 

$field is for (string) (required) 'id', 'slug', 'email', or 'login'

$value is for (string|integer) (required) Search for this field value

    Default: None 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Instagram get user ID from username

From Dev

How to get user Id from username in facebook

From Dev

Get the BuddyPress activity id from the avatar

From Dev

join user id from tblB to user from tblA and get username

From Dev

Get username from ID

From Dev

Get the user id of a username identity 2.0

From Dev

Get Facebook app-scoped user id from global Facebook id, or username

From Dev

How to get a buddypress field of current user?

From Dev

Get email from username of user in Phabricator

From Dev

How to get username from Facebook ID

From Dev

Get youtube username from channel id

From Dev

tweepy how to get a username from id

From Dev

User ID to Username tweepy

From Dev

User ID or Username

From Dev

LINQ Check exist Username then get that User's ID

From Dev

Fetch username and user ID from another table in CodeIgniter

From Dev

Rails 4 - change URL from /user/:id to /:username

From Dev

Get user id and user name from balebot

From Dev

BuddyPress, get url (link) of a group using the group id

From Dev

Instagram: How to get Username/ID from Access-token?

From Dev

How to get username/SID from session id in Windows?

From Dev

Using react, get username from ID inside child component

From Dev

Get Facebook User ID from app-scoped User ID

From Dev

Get Facebook User ID from app-scoped User ID

From Dev

Get a user by username and password with Laravel

From Dev

Get a User Object by username field

From Dev

Get Full Username of Logged In User

From Dev

Get a User Object by username field

From Java

Get Name of User From ID - Discord JDA