How do i get the user id from user login name in wordpress?
Try the get_user_by(...) Function, that returns a WP_User instance that you can then use to extract the User Name.
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 :".
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With