I need save the Contact Form 7 data in a custom table because the Contact Form CFDB7 save me the information in the same colum.

some one khow a plugin make this or maybe a php functions for this?

1 Answer 1


CF7 has an useful hook wpcf7_submit that can be used to process the data sent:

add_action("wpcf7_submit", "SE_379325_forward_cf7", 10, 2);

function SE_379325_forward_cf7($form, $result) {
  if( !class_exists('WPCF7_Submission') )
  $submission = WPCF7_Submission::get_instance();
  if ($result["status"] == "mail_sent") { // proceed only if email has been sent 
    $posted_data = $submission->get_posted_data();

// your insert function:
function save_posted_data($posted_data){
  //var_dump($posted_data); // $posted_data is an array containing all the form fields and values 
  $form_id = $posted_data["_wpcf7"]; // this is the post->ID of the submitted form so if you have more than one you can decide whether or not to save this form fields
  if($form_id !=2) // for exampe you may want to use only data coming from form # id 2
  global $wpdb;


If you want to process data before email is sent here's another hook:

function action_wpcf7_before_send_mail( $contact_form ) { 
  // var_dump($contact_form);

add_action( 'wpcf7_before_send_mail', 'action_wpcf7_before_send_mail', 10, 1 ); 

Consider also issue regarding validation on submission which are also involved in this process.

Here follows a List of available CF7 hooks»

be aware of the implications in terms of GDPR privacy compliance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.