{“how to save astra form submissions to database”}
{/}
<the problem: your contact form data is disappearing>
You’ve set up a clean contact form in Astra Theme. It looks professional, validates properly, and sends emails. But here’s the silent crisis happening right now: Astra doesn’t save your form submissions to your database. Every inquiry, every potential client message, every important contact—it only lives in email. When those emails get deleted, marked as spam, or overlooked in a crowded inbox, that data is gone forever. You could be losing business opportunities without even knowing it. This guide shows you exactly how to save Astra form submissions to database permanently, ensuring no contact data ever disappears again.
{!}
<save astra form submissions to database: the simple solution>
Most tutorials make this sound complicated. They mention plugins, complex database setups, or code that needs to be scattered across multiple files. The truth is much simpler. You need to add one block of code to one specific location. But here’s the part most guides skip: telling you exactly where to put it.
{#}
<the critical first step: use a child theme>
Stop right here if you’re about to edit your main Astra theme files.
Editing /wp-content/themes/astra/functions.php directly is a mistake that will cost you later. When Astra updates (and it will), all your changes disappear. Plus, one typo could break your entire site.
how to create a child theme in 60 seconds:
- Install the “Child Theme Configurator” plugin from your WordPress dashboard.
- Run it and select “Create a New Child Theme”
- Choose “Astra” as the parent theme
- Activate your new child theme
Now you have a safe place to add custom code. Your child theme’s functions.php file is located at:
/wp-content/themes/astra-child/functions.php
{*}
<the exact code that works>
Here’s what to add to your child theme’s functions.php file. Copy and paste this entire block at the end of the file (before closing ?> tag if there is one):
php
// Save Astra contact form submissions to database
add_action(‘init’, function() {
global $wpdb;
$table_name = $wpdb->prefix . ‘astra_contact_submissions’;
$sql = “CREATE TABLE IF NOT EXISTS $table_name (
id INT AUTO_INCREMENT PRIMARY KEY,
submitted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) NOT NULL,
message TEXT NOT NULL
);”;
require_once(ABSPATH . ‘wp-admin/includes/upgrade.php’);
dbDelta($sql);
});
add_filter(‘astra_form_submission_data’, function($form_data) {
if(empty($form_data[‘name’]) || empty($form_data[’email’])) {
return $form_data;
}
global $wpdb;
$wpdb->insert(
$wpdb->prefix . ‘astra_contact_submissions’,
array(
‘name’ => sanitize_text_field($form_data[‘name’]),
’email’ => sanitize_email($form_data[’email’]),
‘message’ => sanitize_textarea_field($form_data[‘message’] ?? ”)
)
);
return $form_data;
});
With this code implemented, you can reliably save Astra form submissions to database without any plugins.
what this does:
- Creates a database table to store submissions
- Automatically saves every form submission to that table
- Doesn’t interfere with normal email sending
- Runs silently in the background
{&}
<how to view your saved submissions>
Once the code is active, every form submission saves automatically. To view them:
Simple Method: Use your hosting control panel’s phpMyAdmin:
- Login to cPanel or your hosting dashboard
- Open phpMyAdmin
- Select your WordPress database
- Find and click wp_astra_contact_submissions (replace wp_ with your prefix)
- Click “Browse” to see all submissions
No extra code needed for viewing. The data is there, clean and accessible.
{=}
<common questions answered:>
Will this affect my form’s design or functionality?
No. It works behind the scenes without changing anything your visitors see.
What if I use multiple contact forms?
It captures all Astra form submissions automatically.
Do emails still send normally?
Yes—this adds database saving alongside existing email functionality.
Is this secure?
Yes, with WordPress’s built-in database security and data sanitization functions.
{/}
<when professional help makes sense>
If you’re uncomfortable editing theme files or want this implemented perfectly, sometimes professional help is the right choice. We’ve solved similar WordPress challenges, from form data issues to development environment problems like the “make is not recognized on Windows” error that can halt development workflows.
For those who’d rather not edit code themselves, check out our WordPress development services on Fiverr. We specialize in clean, effective solutions that solve real problems without unnecessary complexity.
{!}
<your data should be permanent>
Every contact form submission represents someone taking action to connect with you. Whether it’s a potential client, valuable feedback, or an important inquiry, that connection deserves to be preserved. With this simple solution, you ensure no submission ever gets lost to email gremlins again.
The process is straightforward: create a child theme, add the code, and your form data becomes permanently accessible. It’s one of those small changes that makes a big difference in how you manage your website and business communications.
Start saving Astra from submissions to database today and never lose valuable contact data again.
