Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress get user id by login name

Tags:

wordpress

How do i get the user id from user login name in wordpress?

like image 814
fabbrillo Avatar asked Jan 11 '10 12:01

fabbrillo


People also ask

How do I find my WordPress user ID username?

Try the get_user_by(...) Function, that returns a WP_User instance that you can then use to extract the User Name.

How do I find my WordPress username after login?

Getting all the information of current user in wordpress using the predefined function wp_get_current_user(); <? php $current_user = wp_get_current_user(); echo "Username :". $current_user->user_login; echo "Username :".

How do I find my WordPress user ID and password?

Find User ID in WordPress Dashboard First, you'll need to login to your WordPress admin dashboard. From here you can select the user you want the ID of by clicking edit. This will lead you to the user edit page. Here you'll easily be able to see the user's ID in the address bar of your browser.


1 Answers

get_userdatabylogin is now deprecated, it is possible to get the same result via

get_user_by

example :

$user = get_user_by('login','loginname');
if($user)
{
   echo $user->ID;
}

link to the ticket about this change

like image 102
Dalen Avatar answered Oct 08 '22 10:10

Dalen