Over the last week we had a form get noticed by spam bots and get over 100,000 entries without us noticing. While we added Gravity Forms CAPTCHA to stop the spam I still have all those entries in the database to remove. I was only able to do around 1000 via the UI before the server timed out and the process was stopped, but Gravity Forms has a CLI plugin which gives me wp gf
as a command I can run against the site.
I started with small batches (the default page_size
is 20) and once --page_size=10000
worked I looked up the number of entries and matched it to --page_size
which deleted all the spam entries on the form.
wp gf entry delete $(wp gf entry list <form_id> --format=ids --page_size=10000) --force
The command takes the output of wp gf entrie list <form_id>
and sends it to the wp gf entry delete <entry_id> --force
command. Thus listing all the entries based on the --page_size
value and deleting them.
It took about 40 minutes for the command to finish running on around 100,000 entries.
You can find the Gravity Forms CLI docs for entries here.