I am new to WordPress, PHP, and the whole thing. I’ve carried out some googling and located the code beneath, but it surely’s not saving the submission as I would like.
I’ve a type that captures: first-name, last-name, checkin-date, weight, and energy-level. After the consumer hits submit, I need that info saved into wpdg_checkin_forms. I’ve the desk created with the suitable columns.
I’ve verified that the ids for the fields on the CF7 type match the IDs within the code beneath. I am placing the code into the perform.php file.
Thanks upfront!
Right here is the code I discovered and the way I attempted to change:
perform contactform7_before_send_mail( $form_to_DB ) {
//set your db particulars
$mydb = new wpdb('root','','wpdg_checkin_forms','localhost');
$form_to_DB = WPCF7_Submission::get_instance();
if ( $form_to_DB )
$formData = $form_to_DB->get_posted_data();
$firstname = $formData['first-name']
$lastname = $formData['last-name']
$checkindate = $formData['checkin-date']
$weight = $formData['weight']
$energylevel = $formData['energy-level'];
$mydb->insert( 'wpdg_checkin_forms', array( 'first-name' =>$firstname, 'last-name' =>$lastname, 'checkin-date' =>$checkindate, 'weight' =>$weight, 'energy-level' =>$energylevel ), array( '%s' ) );
} remove_all_filters ('wpcf7_before_send_mail');
add_action( 'wpcf7_before_send_mail', 'contactform7_before_send_mail' );