Found out you can pass the --exclude
option to wp user list
to exclude a user by their ID from the list. So let’s assume your user ID is 2
then you could do the following:
wp user delete $(wp user list --field=ID --exclude=2)
And just to be sure all content gets reassigned to you that would be the following command.
wp user delete $(wp user list --field=ID --exclude=2) --reassign=2
Related Posts:
- How to change user_login with wp-cli?
- How can I run a WP-CLI command as authenticated user?
- Can I check which users ran which updates?
- Limit a user only to wp-cli only use
- How to destroy all user sessions via WP-CLI
- Editor can create any new user except administrator
- Confirmation required on email change
- get_current_user_id() returns 0?
- List users by last name in WP_User_Query
- Email user when password is reset by admin
- How to work around “that email address has already been used” error?
- How to redirect a specific user after log-in?
- How to Prevent deleting user accounts in WordPress Back-end?
- How to assign capabilities to user NOT to User Role
- Setting WP Admin passwords to expire
- How do i auto approve new user?
- BuddyPress | Check if user is in current group [closed]
- Pre-populate Username Field
- Redirect after User Activation [closed]
- Getting users who registered 360 days from current date
- Querying Email Addresses for a List of Users with Same Last Name?
- Get all commenters on a post
- Adding tags and inputs to a user’s profile
- Changing default Buddypress avatar affects all site avatars (because gravatar)
- Custom style on profile options page
- Best way to have an per-user customized private section
- How to query users who have empty first_name?
- How to make user accept license agreement before download
- Does wp_delete_user() remove all user content?
- 14,000 WordPress Users. How did they get there?
- Adding second Email address for WP user notifications
- wp_login_form() passing user ID into URL on redirect?
- how to make a profile entry read only except for site managers [closed]
- Managing Users and Creating Groups [closed]
- Upgrade Nightmare – No Posts, Permissions Issues and Can’t Create a new post
- Max no of simultaneous active sessions for a single user
- Search Users base on meta_value & meta_key
- Favorite taxonomy archive page?
- Removing all trace of member profiles
- WordPress API for search
- Fix permissions for users role
- Redirect subscribers to last viewed page after log-in
- User Meta Data in a Sortable Table
- Are there mutiple ways to get usernames (as a hacker)
- Rest api return all users (even without content) to all users
- Column Sorting Code on users.php
- How can I allow an User to publish only 5 posts per month?
- search users using user name and user meta in wordpress
- Where are $current_user->allcaps set?
- WordPress Login Customization for External Authentication
- How to allow registered users to submit the form only 5 times per day?
- Is there any action /filter hook I can use to disable login for some user role?
- Create a “user log”
- How can I do a url redirect to include a wordpress username?
- WP_User_Query combining role and ids
- WordPress current month users
- Allow Users to Modify Some Values of Assigned WordPress Pods [closed]
- Can I Create a Second Admin Level User Role?
- Let logged-in users use radio buttons (yes and no) to exclude their author profile from the user listing
- Make new users automatically approved
- Adding fields to the “Add New User” but the form data not saved into DB
- Admin approval for editing user profile
- Using a custom field value as current users name [closed]
- What does “link” refer to when you delete a user?
- WP Create User – Preventing repeated information
- Editor role can only create/edit/delete users who have one of two roles
- Can’t add user- wrong message “this user name is invalid because it uses illegal characters”
- set automatically email address for WordPress users
- WordPress 5.8 – Hide or Remove personal fields from admin Profile page
- hide user is currently editing warning in admin post page
- Restricting wordpress login sessions for a web app
- change user password REST API
- Use WP cookie to authentificate user on an external app
- Find count of WordPress users by role and search string for user name
- Append USER ID to an outbound link?
- How do I add profile fields in specific section?
- fine-grained capabilities for user related capabilities
- Users activity history
- Is a list of user names or IDs in a custom profile field the best way to create a followers list?
- Custom User Role: Can Edit Own Page, Cannot Create New
- How to restrict Admin from creating new users from Add new user screen in dashboard to only of one domain?
- Get meta key with value for user
- Redirect current user
- Display Users and user url’s
- custom login form, guide me
- Edit dashboard based on user ID
- is_user_logged_in() not working after domain change
- Get the author registration date in the header.php file
- Front end login and page restriction
- How i will get the images of highest scored users?
- Designing a member area on my site
- i need to let a user to add a role from a frontend form
- Integrating Facebook Registration (and Login) on a WordPress page
- WordPress C# User Login
- Create users from frontend without password
- How to get user contact info
- Why does a super admin on multi site get a rest_user_invalid_id error code when requesting user details through REST?
- determine active user browser at the same time
- get Discussion setting in wordpress
- Set a minimal number for next user_id