Amirhossein Hosseinpouramirhp
CV
Maintenance WordPress plugin · Contact Form 7

CF7 Database

Contact Form 7 sends an email and keeps nothing. This keeps it.

Every submission goes into its own database table, with a column for each field of the form. Uploaded files are copied into the media library before Contact Form 7 removes them. From the form's own screen you can view the entries and export them.

Get it on WordPress.org Source on GitHub

Free, GPL-2.0 or later. Published by Pepro Dev; I wrote it and maintain it. Maintenance means it still installs and works on current WordPress; the last release was October 2024. Figures from the WordPress.org API, 30 September 2026.

On WordPress.org2020 to today

What it does

Nothing to configure. Activate it and the next submission is saved.

A table of its own

Submissions go into a separate database table, not into posts, so they do not slow down or clutter the rest of the site.

Columns from the form

The list is built from the form's own fields, with Contact Form 7's tag names as headers, including radio, checkbox and select fields.

Files kept

Uploads are copied into the media library under a unique name and linked from the entry.

Export

Excel, CSV, HTML, plain text, or straight to the printer.

How it saves

The timing matters. Contact Form 7 deletes uploaded files once the email is sent, so the plugin does its work one step earlier.

It hooks wpcf7_before_send_mail, the last moment the submission and its temporary files both exist. It copies each upload into the uploads folder, registers it as an attachment, and puts its URL into the entry in place of the temporary path. Then it writes the entry.

The table is created with dbDelta on activation. Some hosts refused, so 1.5.2 added a way to force it again. 1.8.0 closed a hole that let an unauthenticated request update or regenerate the table's structure.

add_action('wpcf7_before_send_mail', ...);

$submission = WPCF7_Submission::get_instance();
$data  = $submission->get_posted_data();
foreach ($submission->uploaded_files() as $field => $path) {
  // copy out of CF7's temp folder, before it is emptied
  $data[$field] = 'FILEURL:' . $this->save_cf7_attachment($path, ...);
}
$this->save_cf7_submission(..., $data, $form_id);
Condensed from pepro-cf7-db.php, version 2.0.0.

Getting started

Needs Contact Form 7. Tested with Contact Form 7 5.9 and later.

  1. Install

    Plugins, Add New, search for "PeproDev CF7 Database", then Install and Activate.

  2. Submit a form

    There are no settings. The next submission is saved.

  3. Find the entries

    Under the Contact menu, or with View Submissions on the form's edit screen.

Releases

Thirteen versions in the changelog since July 2020. WordPress.org keeps only the current one, so older dates are the changelog's.

VersionReleasedWhat changed
2.0.06 Oct 2024Compatibility with Contact Form 7 5.9 and WordPress 6.6.
1.9.0not datedA security fix; WordPress 6.5 compatibility.
1.8.0not datedFixed an unauthenticated database structure update.
1.5.2not datedA way to force the table to be created, for hosts that refused; Contact Form 7 5.5.
1.5.019 May 2021Moved under the Contact menu; a header filter hook; View Submissions on the form screen.
1.2.0not datedUploaded files saved to the media library.
first release18 Jul 2020Listed on WordPress.org.

Hindsight

Two decisions from 2020 I would make differently.

branch main 6 active projects ↑ 113 releases open-source/cf7-database.md Sari --:-- UTC+3:30 its@amirhp.com