Wordpress save CF7 form in custom table
function contactform7_before_send_mail( ) {
//set your db details
global $wpdb;
$formDataDB = WPCF7_Submission::get_instance();
if ( $formDataDB ) {
$formData = $formDataDB->get_posted_data();
$wpdb->insert( 'contact_form', //table_name
array(
'firstname' => $formData['firstname'],
'lastname' => $formData['lastname'],
'phone' => $formData['phone'],
'email' => $formData['email'],
'address' => $formData['address'],
)
, array( '%s','%s','%s','%s','%s') );
$lastid = $wpdb->insert_id;
}
}
remove_all_filters ('wpcf7_before_send_mail');
add_action( 'wpcf7_before_send_mail', 'contactform7_before_send_mail' );