DefendYourKingdom
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Yordan thank you for answering my question and thank you for putting me a link where I can consult what I need, however I solved it by myself, I put the code inside the answer so that if some other user should have the same problem that I had, he already has the immediate solution, thanks again Yordan good day.
code solution:
/*STORE DATA DA CF7*/ function wpcf7_send_to_external ( $cf7 ) { //external db details $username = 'USERNAME'; $password = 'PASSWORDDB'; $database = 'NAMEDB'; $host = 'HOST'; //create new wpdb instance $mydb = new wpdb($username, $password, $database, $host); //limit hook to only fire on particular form ID (optional) if ( $cf7->id == IDOFYOURCF7 ) { //get select box for different enquiry types (optional) //$type = $cf7->posted_data["your-select"]; //if form type is equal to above value (optional) //if ( $type == 'Form Name' ){ //code added for wordpress 4.9 2018 //$cf7 = WPCF7_ContactForm::get_current(); $submission = WPCF7_Submission::get_instance(); $data = $submission->get_posted_data(); //get posted form fields //these are example form fields $field1 = $data["NAMEOFYOURINPUTINCF7"]; //insert into external db $mydb->insert( //name of external db table 'NAMEOFYOURTABLE', //name of table columns and which fields to insert //these are example fields array( 'NAMEOFYOURVALUEINDB' => $field1 ), //field formats: %s = string, %d = integer, %f = float array( '%s' ) ); //} } } add_action("wpcf7_before_send_mail", "wpcf7_send_to_external");
Viewing 1 replies (of 1 total)