Replace the prefix in wp_users
and wp_usermeta
table names for the one you use.
Make backup of data from both tables before you start to delete users.
DELETE u FROM wp_users u
LEFT JOIN wp_usermeta um1 ON u.id = um1.user_id AND um1.meta_key = 'first_name'
LEFT JOIN wp_usermeta um2 ON u.id = um2.user_id AND um2.meta_key = 'last_name'
WHERE (um1.meta_value IS NULL OR CHAR_LENGTH(um1.meta_value) = 0)
AND (um2.meta_value IS NULL OR CHAR_LENGTH(um2.meta_value) = 0);
DELETE um FROM wp_usermeta um
LEFT JOIN wp_users u ON u.id = um.user_id
WHERE u.id IS NULL;
Related Posts:
- Automatically delete inactive users after 2 months
- Delete all subscribers from wp_users and wp_usermeta a few thousand at a time
- ‘username_exists’ still returns an ID even after deleting record from the database?
- How can I add a user through SQL?
- importing users where password is provided as md5 + much metadata
- Search multiple meta keys at once
- Return ID of authors who have at least one post
- wp_insert_user is not working for me?
- Add user data to table when user is created?
- Bulk create clean user_nicename from user_email with SQL function
- C# user_nicename and Display name blank
- How do I transfer user passwords from one WordPress site to another?
- I am getting mysql_real_escape_string() function error while adding user?
- MySQL query to mass change role of users
- WordPress SQL Issue not returning correct reselts
- create new users in db starting at what ID?
- Delete all users with Editor role and their content mysql
- How do I change the user via SQL?
- is_user_logged_in() not working after domain change
- MySQL query to list users who never signed in
- Confirmation required on email change
- Email user when password is reset by admin
- How to work around “that email address has already been used” error?
- How can I run a WP-CLI command as authenticated user?
- How to Prevent deleting user accounts in WordPress Back-end?
- LEFT JOIN, INNER OUTER JOIN, LEFT OUTER JOIN is driving me crazy. Please help?
- Recover the user that have been deleted
- Adding a photo to each WP user
- WordPress edit_user_profile_update update secondary role
- Check if user is online?
- How to check that if current user (ID) has posts or not
- How to track a users progress through pages by inserting data into WordPress Database?
- How to get the Role Name of the current user? (WordPress)
- how to get recent registered author id?
- Is it possible to duplicate users on a new WordPress install?
- Why don’t first_name and last_name appear when you print_r the WP_User object?
- How to use search_columns in WP_User_Query?
- WordPress to use Drupal users’ credentials
- Authenticate with a Rails app?
- Send Email to Users after Deleting Account
- How to add local users to wordpress without email password?
- WP User Query fails when searching meta queries and search columns
- Call to undefined function wp_insert_user()
- *wpupdateuser* user_login in my WordPress database
- Updating user meta
- Changing a username
- Change the user_login at registration
- How to add a user profile page to frontend?
- Error: How to allow the “contributor” to upload media in wordpress
- Delete users from multisite after they have not logged in for a set amount of time?
- Where is the information about the authors for articles stored?
- User management system similar to wordpress one?
- Restrict access of admin uploads to certain logged-in users?
- how to know when the user is in specific part of the website and when he leaves that part and display the data in the admin dashboard
- Find user by nicename and open profile
- Custom default filtering in the user admin panel disables the other sortable columns
- Register user when after filling contact form
- Is possible to allow user to login with different role?
- Creating user without username and password
- Is this code true or not
- Check for valid email after user inactivity?
- How do I let contributors edit their posts after being approved once?
- Custom Comment Notifications Fire on each Page Load
- Preventing user enumeration: which logic is better?
- 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?
- Custom registration and pending approval
- 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
- How would I restrict certain user levels from editing categories
- How can I set wp_dropdown_users so that it shows only authors?
- What does “link” refer to when you delete a user?
- set automatically email address for WordPress users
- 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?
- Users activity history
- How to destroy all user sessions via WP-CLI
- Is a list of user names or IDs in a custom profile field the best way to create a followers list?
- How to restrict Admin from creating new users from Add new user screen in dashboard to only of one domain?
- Designing a member area on my site
- Link to Authors blog posts
- view and update form only for registered users
- Redirect based on log-in status per JavaScript
- i need to let a user to add a role from a frontend form
- Integrating Facebook Registration (and Login) on a WordPress page
- 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?
- Sorting Users page admin column with ACF field
- Can we get user profile page using user_id in the URL?