Many functions that we write about require you to know what the user ID is and we get asked a lot about how to find the user ID. Just as with posts, pages, categories, etc, the ID is very easy to find and almost always just a matter of viewing the preview URL when hovering over the user to you need the ID in the user list.
First, in your WordPress admin go to Users > All Users. Hover your cursor over the user that you want to find the ID.
1. Find the User ID in WordPress Dashboard
While hovering your cursor over the user check the preview URL at the bottom of your browser, in Chrome this will be at the bottom left or right of the window as below in our screenshot.
You will see the URL contains ‘user_id=XXXX’ this number is the user’s ID.
2. See All WordPress User IDs (Using the Reveal IDs Plugin)
If you want to see all user’s IDs in your WordPress dashboard you can use the Reveal IDs plugin.
After activating this plugin just head to Users>all users and you’ll see a column with the user’s ID.
This plugin is a great way to display WordPress user IDs in the admin for quick reference.
3. Get the Current User ID (using PHP)
The easiest way to get the currently logged-in user ID with PHP is to use the get_current_user_id() function. This is the ideal solution if you’re building custom code and need the currently logged-in user’s ID.
echo 'The current logged in user ID is: '.get_current_user_id();
For more information on finding user ID, let us help you accordingly, from start to finish, with one-Time fixes, custom plans, or monthly routines for your WordPress website.