wp user get
Overview
Inspect a single WordPress user account and retrieve any field — ID, email, role, registration date, and more. Essential for verification scripts, auditing, and extracting data before bulk operations.
What It Does
wp user get fetches a single user record from WordPress and displays all or selected fields. You can target the user by ID, login slug, or email.
Syntax
wp user get <user> [OPTIONS]
Arguments & Options
| Flag | Description |
|---|---|
--field=FIELD | Return only one field value (for scripting) |
--fields=FIELDS | Comma-separated list of fields |
--format=FORMAT | Output format: table, json, yaml, csv |
Available Fields
| Field | Description |
|---|---|
ID | User ID |
user_login | Username |
user_email | Email address |
display_name | Public display name |
user_registered | Registration datetime |
user_url | User website |
roles | Assigned roles |
user_status | Status (0 = active) |
Basic Usage
Get all user details
wp user get john
Output:
+------------------+------------------------------+
| Field | Value |
+------------------+------------------------------+
| ID | 14 |
| user_login | john |
| user_email | john@example.com |
| display_name | John Smith |
| user_registered | 2024-01-15 09:32:11 |
| roles | editor |
+------------------+------------------------------+
Get a single field (for scripting)
wp user get john --field=user_email
Get as JSON
wp user get 14 --format=json
Real-World Scenarios
Scenario 1: Check a user's current role before reassigning
ROLE=$(wp user get 14 --field=roles)
echo "Current role: $ROLE"
if [[ "$ROLE" == "subscriber" ]]; then
wp user set-role 14 editor
fi
Scenario 2: Verify a user exists before deletion
if wp user get old-author &>/dev/null; then
wp user delete old-author --reassign=1
else
echo "User not found — skipping"
fi
Scenario 3: Capture registration date for audit log
REG=$(wp user get editor1 --field=user_registered)
echo "editor1 registered on: $REG"
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
Error: Invalid user ID, login or email | Wrong identifier | Use wp user list to find the exact value |
| Field returns empty | Field does not exist | Check valid field names with --format=json |
Quick Reference
wp user get <user> # Full info table
wp user get <user> --field=user_email # Single field
wp user get <user> --format=json # JSON output
wp user get <user> --fields=ID,user_login,roles
Next Steps
wp user update— modify user fields.wp user list— list all users.wp user meta— access custom user meta data.