Remove all Gravity Forms entries at once

Hi!

I just installed Grafivty Forms CLI, convinced it would allow me to remove all existing GF entries at once with the wp gf entry delete command.

That’a good way to cleanup a staging or test environment.

But I couldn’t find the argument allowing to remove them all. --all won’t do it.

Any help would be appreciated.

Thanks

-all isn’t a supported argument. You can suggest adding support for that argument using the Labs feedback form.

Try the following, replacing <form-id> with your form ID:

wp gf entry delete $( wp gf entry list <form-id> --format=ids ) --force
1 Like

I just did that but it deletes only 20 entries at once. Is there a way to overcome this limitation to remove all the entries at once?

Try adding a page_size parameter, as well:

wp gf entry delete $( wp gf entry list <form-id> --page_size=5000 --format=ids ) --force
1 Like

One thing to note with that argument is the request can timeout if you set it too high for your hosting environment.

It’s also worth noting that the latest Gravity Forms version updated the bulk permanently delete entries action on the Forms list page in the admin to use the background processor to delete them in smaller batches to reduce the risk of timeouts.

1 Like

Thanks guys for these advices, it works!

It was pretty quick, and it didn’t timeout on my setup for the 5000ish entries of my main form.

Still, my ultimate goal here, is to clear all the entries, from all forms, when moving my live database to local, or preparing to share it with someone else who just shouldn’t get these data.

So being able to target all the forms at once would be even better!

Does it make sense to you? Or maybe you have another approach to suggest?

Thanks for your reactivness by the way, very appreaciated :slight_smile:

Try truncate the entry tables in your local dev environment. It’ll be the fastest:

wp db query "TRUNCATE TABLE wp_gf_entry;TRUNCATE TABLE wp_gf_entry_meta;TRUNCATE TABLE wp_gf_entry_notes;"