Skip to main content

Tech

Does Contact Form 7 Store Data? No. How to Save Entries

Contact Form 7 saves no submissions to the database. We checked the CF7 6.2.3 code: what Flamingo skips, where wpcf7_uploads files go, and 3 ways to keep entries.

Contact Form 7 powers millions of WordPress sites, and on most of them the only copy of an inquiry is an email in someone’s inbox. When that email bounces, lands in a spam folder, or is deleted by mistake, there is no second copy to fall back on. People then search for the Contact Form 7 database table, find nothing, and assume they have misconfigured something.

Nothing is misconfigured. Storage was never there. This article shows exactly what the current version does and does not keep, what the standard companion plugin records, and the three practical ways to make sure no inquiry is lost. Everything below was checked against the real distribution, not the documentation.

What we tested

We pulled both plugins straight from the official repository and read the code.

ItemValue
contact-form-7.zipmd5 68b35dd1c8c1946bf8ec85a56d1763c0
Contact Form 7 version6.2.3 (Requires PHP: 8.3)
flamingo.zipmd5 aa8093c4ce33f07d9ad891c5c5d60254
Flamingo version2.6.4
PHP used for the snippet checks8.3.6 (CLI)

One detail worth noting before anything else: Contact Form 7 6.2.3 declares Requires PHP: 8.3. On a server still running PHP 8.1 or 8.2, WordPress will hold the plugin back at an older release, which means you may be reading about behaviour your site does not have yet.

Contact Form 7 stores nothing, and the code proves it

Searching the whole plugin directory for the three things a plugin needs in order to persist data returns nothing at all:

grep -rn '\$wpdb->insert\|dbDelta\|CREATE TABLE' contact-form-7/
#=> no matches

There is no table, no custom post type for entries, and no option row holding submissions. Reading includes/submission.php confirms the lifecycle. A submission object is created for the request, validated, checked against the acceptance box and the spam filters, handed to the mail routine, and destroyed. The only persistent write the plugin makes is update_post_meta() against the form post, which stores configuration, not entries.

That design is deliberate and it is not a bug. It also means a single point of failure: your mail server. If you are seeing missing notifications on top of missing records, start with Contact Form 7 Not Sending Email: 3 Fixes, because storage will not help you if the delivery path is broken.

The Flamingo bridge lives inside Contact Form 7, not Flamingo

This surprises most people. Flamingo is presented as the official way to save Contact Form 7 messages, so you would expect it to listen for CF7 events. It does not.

grep -rn 'wpcf7' flamingo/ | wc -l
#=> 0

Zero occurrences. The integration ships in Contact Form 7 itself, at modules/flamingo.php, and hooks wpcf7_submit:

add_action( 'wpcf7_submit', 'wpcf7_flamingo_submit', 10, 2 );

The practical consequence: your inquiry history is governed by the Contact Form 7 release installed on the site, not by the Flamingo release. When storage behaviour changes, it changes in a CF7 update. If Flamingo’s classes are not loaded, the function returns immediately and the submission is dropped with no notice and no log entry.

Three statuses are stored. Three are thrown away.

Inside that module, the list of statuses eligible for storage is explicit:

$cases = (array) apply_filters( 'wpcf7_flamingo_submit_if',
	array( 'spam', 'mail_sent', 'mail_failed' )
);

if ( empty( $result['status'] ) or ! in_array( $result['status'], $cases, true ) ) {
	return;
}

Contact Form 7 can finish a submission in six states. Three are recorded and three are discarded:

StatusStored by FlamingoWhen it happens
mail_sentYesNormal successful submission
mail_failedYesAccepted, but wp_mail() returned false
spamYesFlagged by a spam filter, flagged in the list
validation_failedNoA required field was empty or malformed
acceptance_missingNoThe consent checkbox was left unticked
abortedNoSomething stopped the send on wpcf7_before_send_mail

validation_failed and acceptance_missing are reasonable to drop; the visitor is still on the form and can correct the field. aborted is the dangerous one. Any snippet or integration that sets the $abort flag - a custom blocklist, a CRM push that throws, a payment check - produces a submission that the visitor believes was sent, that never generates an email, and that is never written anywhere. From the admin side it is invisible.

If you want those recorded, the filter is already there:

add_filter( 'wpcf7_flamingo_submit_if', function ( $cases ) {
	$cases[] = 'aborted';
	return $cases;
} );

Two more exclusions are worth knowing. A form tag carrying the do-not-store feature is stripped from the stored fields, and if a submission’s meta contains do_not_store, the whole record is skipped. Both are useful for privacy work, and both will quietly explain a “missing” field if someone enabled them months ago.

WordPress Plugin

Keep every Contact Form 7 submission, without writing a table.

Frontierline Forms is an extension for Contact Form 7 that stores submissions in its own table, shows a searchable log in the WordPress admin, and exports to CSV. Database storage and CSV export are free and unlimited, and the plugin is distributed through the official WordPress.org repository. Slack and Chatwork notifications, auto-reply email, and AES-256 encryption are in the Pro version (from $39.99/year).

Get Frontierline Forms Free → Get help on WordPress.org

Uploaded files are deleted, whatever you store

File fields are the second common surprise. Contact Form 7 moves an upload into a temporary directory - wp-content/uploads/wpcf7_uploads/ unless WPCF7_UPLOADS_TMP_DIR is defined - attaches it to the notification email, and then removes it. The cleanup runs in two places: the submission object’s destructor calls remove_uploaded_files(), and the plugin also registers wpcf7_cleanup_upload_files on WordPress’s shutdown hook.

What reaches storage is the posted value, which is the file name as a string. If you save that into a table and build an admin link from it, the link will 404, because the file is already gone by the time anyone clicks. The only copies that survive are the attachments on the notification email.

So if attachments matter to your business - applications, quotes with drawings, support screenshots - treat the mailbox as the archive, or copy the file into the media library inside your own hook before the request ends.

Writing your own table: use the right hook

Most tutorials reach for wpcf7_before_send_mail. Reading the source shows why that is the wrong default. The hook is only reached while the submission status is still init, which is to say after validation, after the acceptance check, and after the spam check have all passed. Spam-flagged submissions never get there. And it is called like this:

do_action_ref_array( 'wpcf7_before_send_mail', array(
	$this->contact_form,
	&$abort,
	$this,
) );

$abort is passed by reference. Your callback sits directly in the path of the notification email, so a database error or an uncaught exception in your save routine can stop the message being sent. The storage you added to avoid losing inquiries becomes the reason an inquiry is lost.

wpcf7_submit is the safer hook. It fires once for every submission, after the result is final, with the status in hand:

add_action( 'wpcf7_submit', function ( $contact_form, $result ) {
	global $wpdb;

	$submission = WPCF7_Submission::get_instance();

	if ( ! $submission ) {
		return;
	}

	$status = $result['status'] ?? '';

	if ( ! in_array( $status, array( 'mail_sent', 'mail_failed', 'spam', 'aborted' ), true ) ) {
		return;
	}

	$posted = $submission->get_posted_data();
	unset( $posted['_wpcf7'], $posted['_wpcf7_version'], $posted['_wpcf7_unit_tag'] );

	$wpdb->insert(
		$wpdb->prefix . 'cf7_entries',
		array(
			'form_id'    => $contact_form->id(),
			'status'     => $status,
			'remote_ip'  => (string) $submission->get_meta( 'remote_ip' ),
			'user_agent' => (string) $submission->get_meta( 'user_agent' ),
			'fields'     => wp_json_encode( $posted, JSON_UNESCAPED_UNICODE ),
			'created_at' => current_time( 'mysql' ),
		),
		array( '%d', '%s', '%s', '%s', '%s', '%s' )
	);
}, 10, 2 );

With the table created on activation:

function mysite_cf7_entries_table() {
	global $wpdb;
	require_once ABSPATH . 'wp-admin/includes/upgrade.php';

	$table   = $wpdb->prefix . 'cf7_entries';
	$charset = $wpdb->get_charset_collate();

	dbDelta( "CREATE TABLE {$table} (
		id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
		form_id bigint(20) unsigned NOT NULL,
		status varchar(20) NOT NULL,
		remote_ip varchar(45) DEFAULT '',
		user_agent text,
		fields longtext,
		created_at datetime NOT NULL,
		PRIMARY KEY  (id),
		KEY form_id (form_id),
		KEY created_at (created_at)
	) {$charset};" );
}
register_activation_hook( __FILE__, 'mysite_cf7_entries_table' );

Both snippets were checked with php -l on PHP 8.3.6. Put them in a small site-specific plugin rather than functions.php, so a theme switch does not take your inquiry history with it.

Four things this code does on purpose: it accepts mail_failed so delivery problems still leave a record, it accepts aborted so a blocked send is visible, it strips the three internal _wpcf7* fields that would otherwise bloat every row, and it stores JSON rather than a serialised PHP array so the data stays readable from outside WordPress.

What it deliberately does not do is handle the parts that get expensive: an admin screen, search, pagination, CSV export, retention and deletion, and personal-data requests. That is the honest cost comparison - the insert is twenty lines, and the surrounding operational work is not.

Spam handling sits next to this decision. If your table is filling up with junk rather than leads, the layered approach in Solving Contact Form 7’s Spam and Submission Logging Problems with Custom Code is the companion piece to this one.

The settings-only route

If you would rather not own that code, an extension plugin does the same job from the admin. Frontierline Forms writes every submission to its own table, lists it with search in the dashboard, and exports the result set to CSV with a UTF-8 BOM so Excel opens it without garbled characters. The setup is covered in How to Save Contact Form 7 Submissions to Your Database, and the export side in Contact Form 7 Export to CSV.

Your existing form tags and mail templates are untouched; storage is a setting, not a rebuild.

Choosing between the three

ApproachGood forWatch out for
FlamingoA free history of normal submissions, no codeDrops validation_failed, acceptance_missing and aborted; stores entries as posts, which grows wp_posts
Custom tableFull control of schema, joins with other dataYou own the admin UI, export, retention, and the hook pitfalls above
Extension pluginSearchable log plus CSV without developmentAnother plugin to keep updated

For most sites the deciding factor is not the storage itself but what happens afterwards: can a non-developer find last Tuesday’s inquiry, and can you hand the quarter’s leads to sales as a file. Flamingo answers the first question and not the second; a custom table answers neither until you build it.

Free, unlimited database storage

Stop relying on your inbox as the archive.

Frontierline Forms saves Contact Form 7 submissions to the database, keeps a searchable history in the WordPress admin, and exports to CSV - all in the free version, with no row limit and no form limit. Confirmation screens, completion screens, and multi-step forms are included too, and your existing CF7 form tags carry over unchanged.

See what the free version includes → Ask a question on WordPress.org

Summary

Contact Form 7 6.2.3 keeps no record of submissions - verified in the source, not inferred from the documentation. Flamingo adds a history, but through a bridge that ships inside Contact Form 7 and that stores only spam, mail_sent, and mail_failed, so blocked and aborted submissions disappear silently. Uploaded files are always deleted after the notification email is built, whatever your storage does. If you write your own table, hook wpcf7_submit rather than wpcf7_before_send_mail, so spam and delivery failures are still recorded and a bug in your callback cannot abort the email. If you would rather configure than code, an extension plugin covers storage, search, and CSV export without touching your existing forms.

Frequently Asked Questions

The questions below summarise the points above for quick reference.