Documentation
How to Save Contact Form 7 Submissions to Your Database
Contact Form 7 (CF7) does not save submission data by default. This guide explains how to store form submissions in your database and view a history log in the admin dashboard, comparing a no-code, settings-only approach with a custom-built one.
Contact Form 7 (CF7) does not save any submission data by default. If an email notification gets garbled or is caught by a spam filter, the entire inquiry is lost — and you’re left with no way to answer “who contacted us last week, and what did they say?”
By saving submissions to your database and keeping a history in the admin dashboard, you can eliminate this gap entirely.
Why saving submissions to the database matters
Emails get lost. A server delivery failure, Gmail’s spam filtering, an accidental deletion by whoever manages the inbox — if any of these happen and you haven’t saved the data elsewhere, there’s no way to recover it. Losing an important lead or quote request is a direct business loss. Keeping a copy in the database gives you a second record alongside the email, and lets you search and aggregate the data later.
Method 1: Complete it entirely from the settings screen (no code, recommended)
You can save submission content to the database using only the WordPress admin settings, without touching functions.php. With Frontierline Forms, the following steps get you there.
Steps
- Enable storage: Turn on database storage of submission content in the settings.
- Check saved fields: Confirm which fields are stored — name, email, message, submission date/time, and so on.
- View the history: Search and browse submission history from the list in the admin dashboard.
- Send a test submission: Submit the form and confirm a new record appears in the list.
The plugin handles the storage table design and sanitization for you, so there’s no code to maintain. Saved history can be exported directly with full CSV export.
Method 2: Build it yourself with wpcf7_before_send_mail (advanced)
If you’d rather write your own code, you can capture submission data through CF7’s wpcf7_before_send_mail hook and save it to a custom table.
add_action('wpcf7_before_send_mail', function ($form) {
global $wpdb;
$submission = WPCF7_Submission::get_instance();
$data = $submission ? $submission->get_posted_data() : [];
$wpdb->insert($wpdb->prefix . 'cf7_entries', [
'created_at' => current_time('mysql'),
'name' => sanitize_text_field($data['your-name'] ?? ''),
'email' => sanitize_email($data['your-email'] ?? ''),
'message' => sanitize_textarea_field($data['your-message'] ?? ''),
]);
});
You’ll need to create the storage table in advance using dbDelta().
Where a manual implementation gets tricky
- You need to design and create the table: You’ll have to write separate code that runs
dbDelta()to create the table when the plugin is activated. - You need to build your own list/search UI: Saving the data isn’t enough — you can’t view it. Building a list view, search, and detail display in the admin dashboard yourself is a significant amount of work.
- Risk of missing sanitization: If you neglect to sanitize input values, displaying the saved data later can introduce vulnerabilities like XSS.
Saving the data might only take a few lines of code, but building a usable viewing UI adds up fast. Rather than building a production-ready admin screen from scratch, Method 1 — completing everything through settings — is the more practical choice.
Differences between the Lite and Pro versions
| Lite (Free) | Pro | |
|---|---|---|
| Records saved | Unlimited, permanent | Unlimited, permanent |
| Search and filtering | Yes | Yes |
| Full CSV export | Yes | Yes |
| Encrypted storage | — | Yes |
Saving, listing, and CSV export are all free. If you need encrypted storage of submission data or external notifications and auto-replies, go with the Pro version.
Summary
Because CF7 doesn’t save submission content by default, there’s a real risk of losing data if email delivery fails. A custom implementation with wpcf7_before_send_mail is possible, but building the viewing UI yourself is a heavy lift. If you’d rather handle saving, listing, and export entirely through settings, a dedicated plugin is the faster route — and saving, listing, and CSV export can all be tried for free.
If you want database storage of submission logs alongside full CSV export, Slack/Chatwork/spreadsheet notifications, and multi-step forms — all set up through settings alone — consider installing Frontierline Forms.
Frontierline Forms
This setup takes just a checkbox in the admin.
Add alerts, submission logging, CSV export and multi-step forms without writing code — all from the settings screen. The 5-site / unlimited license lets agencies cover form maintenance across many client projects at once. Your license key is issued instantly on payment.