The Bonnie Situation
Guides · Data retention

How to auto-delete Contact Form 7 submissions

Contact Form 7 doesn't store anything, but the plugin you added to keep submissions probably keeps them forever. Here's how to delete them on a schedule, with or without a plugin.

By Nick Sullivan · Updated 12 November 2026

Contact Form 7 itself never stores a submission, so there's nothing in it to delete. The copies you need to expire are the ones kept by whichever storage plugin you added, plus the emails in your inbox.

Here's what each storage plugin does on its own:

  • Flamingo moves spam to the trash after 30 days. Real messages stay until someone deletes them.
  • CFDB7 has no retention setting. Every row stays in its table until someone deletes it.
  • The Bonnie Situation deletes each submission once it's older than the number of days you choose, in a daily sweep.

Option 1: The Bonnie Situation (no code)

  1. Install The Bonnie Situation from WordPress.org alongside Contact Form 7. It captures every submission from then on.
  2. Go to Bonnie → Settings. Under Retention, set Retention policy to Delete entries permanently after the retention window. It starts on Retain entries indefinitely, so this step matters.
  3. Set Days to retain before deleting. It defaults to 30 and the minimum is 1. Not sure what to pick? See how long to keep contact form submissions.
  4. Save. The next daily sweep deletes anything older than the window.

Every sweep writes a row to an audit log, so you can show what was deleted and when. If a sweep fails, or none has succeeded for 48 hours, Bonnie flags it in Tools → Site Health and with an admin notice, so data is never kept longer than you think.

The sweep runs on WP-Cron, which only fires when someone visits the site. On a quiet site, have your host call wp-cron.php from a real cron job so the sweep runs on time.

Bonnie Pro adds a separate window for each form, a trash with a restore period instead of instant deletion, wp bonnie purge for running the sweep from WP-CLI, and email, Slack or webhook alerts if the cleanup stops. Compare Free and Pro →

Already have years of Flamingo or CFDB7 entries?

Go to Bonnie → Settings → Import. Bonnie copies your existing entries across under your retention window, and skips anything that's already older than it. It doesn't change the source plugin, so once you've checked the import, delete the old copies there. The Flamingo and CFDB7 comparison pages walk through the clean-up.

Option 2: a code snippet for Flamingo

If you'd rather keep Flamingo, you can schedule the deletion yourself. Flamingo saves each message as a WordPress post of type flamingo_inbound, so a daily WP-Cron job can remove the old ones. Put this in a small custom plugin or a code-snippets plugin, and try it on a staging copy first:

add_action( 'init', function () {
    if ( ! wp_next_scheduled( 'my_flamingo_purge' ) ) {
        wp_schedule_event( time(), 'daily', 'my_flamingo_purge' );
    }
} );

add_action( 'my_flamingo_purge', function () {
    $days = 30; // Your retention window.
    $ids  = get_posts( array(
        'post_type'      => 'flamingo_inbound',
        'post_status'    => array( 'publish', 'flamingo-spam', 'trash' ),
        'date_query'     => array( array( 'before' => $days . ' days ago' ) ),
        'fields'         => 'ids',
        'posts_per_page' => 500,
    ) );
    foreach ( $ids as $id ) {
        wp_delete_post( $id, true ); // true = skip the trash.
    }
} );

What a snippet like this doesn't give you:

  • No record. Nothing logs what was deleted, which is the thing you'll want if anyone asks.
  • No warning if it stops. If WP-Cron stops firing or the snippet is removed, deletion silently stops too.
  • Flamingo still stores IP addresses. Each message keeps the sender's IP and user agent until it's deleted.

CFDB7 keeps submissions in a single table, wp_db7_forms, and uploaded files in wp-content/uploads/cfdb7_uploads. Deleting old rows by date is possible with SQL, but the uploaded files stay behind unless you remove them too.

Don't forget the inbox

Every Contact Form 7 submission is also an email. If your retention window is 30 days but the notification emails sit in a shared inbox for five years, the window isn't doing much. Google Workspace and Microsoft 365 both let an admin set retention rules on a mailbox or label, so the emails can expire on the same schedule.

Quick answers

Can Contact Form 7 delete submissions automatically?

There's nothing to delete in Contact Form 7 itself, because it doesn't store submissions. Automatic deletion has to come from the storage plugin that keeps the copies. The Bonnie Situation does it in a daily sweep after the number of days you choose.

Does Flamingo delete old messages?

Only spam. Flamingo moves spam to the trash after 30 days. Other messages stay until someone deletes them, unless you add your own scheduled clean-up.

Does CFDB7 have a retention setting?

No. CFDB7 keeps every submission in its table, and uploaded files in its uploads folder, until someone deletes them.

How do I make sure the auto-delete actually runs?

WP-Cron only runs when the site gets visits, so trigger wp-cron.php from a real cron job on low-traffic sites. The Bonnie Situation also warns you in Site Health if no cleanup has succeeded for 48 hours.