I am trying to delete thousands of users at once. After seeing that I can only display up to 999 user records at once using the “Screen Options” menu I thought that might be ok. But upon clicking delete I get a “Request-URI Too Large” error.
How can I delete these users without doing it 10 or 20 at a time?
I would shy away from trying to do this is SQL. It is possible but probably not necessary and is more prone to error that using WordPress Core functions.
You could use
get_users()
orWP_User_Query
to retrieve your users but given that you only want to keep two users and you only need theID
forwp_delete_user
those are pretty heavy. I’d just run a quick query on the user table and loop through it.That is irreversible.
Obviously you will have to supply the two user
ID
s for the users you want to keep.Test on trash data and make sure that is what you really want to do. Please also note that unless a second parameter is passed
wp_delete_user
will delete posts associated with the deleted user.This link left by dalbaeb solved my problem: http://www.scriptol.com/wordpress/mass-delete-users.php
It deletes all the required records
Thanks all!