If you’re locked out of your WordPress admin area, WP-CLI can get you back in.
Find your username
wp user list --role=administrator --fields=ID,user_login,user_email
This lists your admin users with their username and email address.
Option 1: Send a password reset email
wp user reset-password yourusername
WordPress emails a password reset link to that user’s email address.
Option 2: Set a new password yourself
wp user update yourusername --prompt=user_pass
You’ll be asked to type the new password. Nothing appears on screen as you type – that’s normal. Press Enter when you’re done.
Create a new admin user
If you’d rather create a new admin account, for example for a developer:
wp user create newusername [email protected] --role=administrator
WP-CLI creates the user and shows a strong password on screen. Copy it somewhere safe straight away.
Remove a user you no longer need
wp user delete oldusername --reassign=yourusername
The --reassign part gives their posts and pages to another user, so nothing is lost.