Dashboard URLs, PHP, database, WP-CLI, plugins, and programmatic lookups—one reference for support and custom code
Why the User ID matters
It is the stable handle WordPress uses internally for permissions, meta rows, author attribution, and many plugin settings. You will see it in troubleshooting steps, custom if ( $user_id === 3 ) snippets, and direct database work—so knowing how to read it safely saves time.
Method 1: WordPress admin (easiest)
Your own account
- Log into
wp-admin. - Open your avatar menu (top right) or go to Users → Profile.
- Inspect the address bar. The query string includes your ID:
https://yoursite.com/wp-admin/user-edit.php?user_id=3
The number after user_id= is your User ID (here: 3).
Any other user
- Go to Users → All Users.
- Hover a username (or use Edit) and check the link preview or open the edit screen.
https://yoursite.com/wp-admin/user-edit.php?user_id=5
That value is the user’s ID. Clicking through to the profile editor always exposes the same user_id parameter.
Method 2: Users list quick check
Users → All Users → click a username or Edit → confirm user_id=X in the URL. This is the same signal as Method 1, optimized for scanning several accounts.
Method 3: PHP (developers)
Add snippets to a child theme functions.php or a small custom plugin. Remove them when you no longer need the output.
Admin footer notice (logged-in user only)
add_action( 'admin_footer', 'show_current_user_id' );
function show_current_user_id() {
$current_user = wp_get_current_user();
echo '<div style="position:fixed;bottom:10px;right:10px;background:#2271b1;color:#fff;padding:8px 12px;border-radius:4px;z-index:9999;">';
echo 'Your User ID: <strong>' . esc_html( (string) $current_user->ID ) . '</strong>';
echo '</div>';
}
Shortcode [current_user_id]
add_shortcode( 'current_user_id', function () {
if ( ! is_user_logged_in() ) {
return 'Please log in to see your User ID.';
}
$user = wp_get_current_user();
return 'Your User ID: ' . esc_html( (string) $user->ID );
} );
Place [current_user_id] in any post or page that allows shortcodes (and that the target user is allowed to view).
Security note
Do not expose arbitrary users’ IDs on the public front end unless you understand the privacy and enumeration trade-offs. Prefer admin-only hooks or role-restricted output.
Method 4: Database (phpMyAdmin)
- Open phpMyAdmin from your host.
- Select the WordPress database.
- Open the users table—default name is
wp_users, but prefixes likewpxx_are common. - The ID column lists User IDs.
Find one account by login:
SELECT ID, user_login, user_email, display_name
FROM wp_users
WHERE user_login = 'yourusername';
List everyone (adjust table prefix):
SELECT ID, user_login, user_email
FROM wp_users
ORDER BY ID;
Method 5: WP-CLI
With SSH and WP-CLI available inside the site root:
# List users with IDs
wp user list
# One user’s ID
wp user get yourusername --field=ID
# Current user context inside WP-CLI eval (see WP-CLI docs for bootstrapping)
wp eval 'echo (int) get_current_user_id();'
wp eval runs in CLI context where no browser session exists; use it when you already know which user to load, or pair with wp user get as above.
Method 6: Plugin column
Install a reputable “Show IDs” / “Reveal IDs” style plugin from Plugins → Add New, activate it, then open Users → All Users. Many add an ID column so you can scan without opening each profile.
Quick reference: where the ID appears
| Location | Where to look |
|---|---|
| Edit profile URL | user_id=3 (or any number) in the query string |
| Users list | Hover username or open edit link; same parameter |
| Database | {prefix}_users table, ID column |
| WP-CLI | wp user list / wp user get … --field=ID |
| PHP | get_current_user_id() or $current_user->ID |
Common use cases
| Use case | Why the ID helps |
|---|---|
| Custom code | Target users with if ( (int) $user_id === 3 ) and similar guards |
| Plugin settings | Some tools whitelist admins or map capabilities by numeric ID |
| Database fixes | Join usermeta rows to the correct account via user_id |
| Multisite | Correlate accounts across sites in the network tables |
| Support | Developers often ask for the ID to reproduce permission bugs |
| Author attribution | Bulk or emergency post-author changes reference post_author user IDs |
Programmatic lookup by login or email
// By username (login)
$user = get_user_by( 'login', 'john_doe' );
$user_id = $user ? (int) $user->ID : 0;
// By email
$user = get_user_by( 'email', '[email protected]' );
$user_id = $user ? (int) $user->ID : 0;
// Current visitor (0 if not logged in)
$current_user_id = get_current_user_id();
Always check that $user is truthy before reading ->ID to avoid notices on missing accounts.
Fastest path for most people
Use Method 1: open your profile or any user’s edit screen and read user_id from the URL. For bulk or automation, pair Method 4 or Method 5 with backups and staging first.
Frequently asked questions
- Where is my WordPress User ID in the dashboard?
-
Open Users → Profile (your account) or Users → All Users and edit a user. The address bar contains
user-edit.php?user_id=N—N is the User ID. - Is the User ID the same as the username?
-
No. The username is text in
user_login; the ID is an integer primary key. They are linked but not interchangeable in code or SQL. - Can User IDs change?
-
Under normal operation, no—the ID is assigned at user creation and stays fixed. Migrations or imports can remap data; always verify in the database after unusual imports.
- What if my table is not named wp_users?
-
Check
wp-config.phpfor$table_prefix. The users table is{prefix}users(e.g.wpxx_users). - How do I get the ID in PHP for the logged-in user?
-
Use
get_current_user_id()or(int) wp_get_current_user()->ID. Both return0when no user is logged in.
Comments
No comments yet. Be the first to reply.