Hallo zusammen,
ich weiß, das Thema wurde schon ein paar mal behandelt, aber irgendwie habe ich jetzt in einigen Tagen Suche immer noch nicht das passende gefunden. Vllt. könnt ihr mir ja weiterhelfen. Ich habe für meine Arbeit eine Wordpress Seite aufgestellt, auf der man sich registreiren kann. Anschließend sollen Besucher ein Formular ausfüllen, soweit so gut. Jetzt wäre die Frage, ob es eine Möglichkeit gibt, die eingegebenen Daten (Contact form 7) in einer externen Datenbank zu speichern, da wir noch ein Programm zum Verarbeiten der Daten zwischenschalten müssen (sollen kombiniert werden mit anderen Formular-Daten).
Was ich versucht habe:
Bestehende Plugins installiert, die speichern jedoch nur in der Wordpress Datenbank ab.
Eigenes Plugin aus dem Internet, hat sich installiert, gab keine Fehlermeldung, aber in der Zieldatenbank steht trotzdem nix drin.
Versucht, die Wordpress Datenbank selber nach den entsprechenden Daten zu durchsuchen, aber das ist recht mühsam und es soll ja automatisch funktionieren...
Wäre es alternativ möglich, ein bestehendes Plugin so umzuschreiben, dass es an eine externe DB schickt?
Vielen Dank schon mal im Voraus, ich hoffe, ihr habt eine Idee :)
Ps.: Das Plugin, das ich im Internet gefunden hab (vielleicht hat ja jemand Verbesserungsvorschläge, um es zum Laufen zu bringen):
<?php
/*
Plugin Name: Contact Form 7 to External DB
Plugin URI:
Description: This plugin uses the wpcf7_before_send_mail hook to post a specific form to an external database. Upon use the details for your external database will need to be entered. Private use only.
Author:
Version: 0.2
Author URI:
*/
function wpcf7_send_to_external ( $cf7 ) {
//external db details
$username = 'username';
$password = 'passw';
$database = 'username';
$host = 'host ip';
//create new wpdb instance
$mydb = new wpdb($username, $password, $database, $host);
//limit hook to only fire on particular form ID (optional)
if ( $cf7->id == xxx) {
//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['select menu-657 "Mr." "Mrs." "Divers"'];
$field2 = $data['text* your-surname'];
$field3 = $data['text* your-name'];
$field4 = $data['date* DateofBirth'];
$field5 = $data['email* your-email'];
$field6 = $data['tel* Phone'];
$field7 = $data['text* Street'];
$field8 = $data['text* ZIP'];
$field9 = $data['text* City'];
$field10 = $data['checkbox 1 "1"'];
$field11 = $data['checkbox 2 "2"'];
$field35 = $data['number choose min:09 max:22'];
$field37 = $data['acceptance acceptance-dataprotect'];
//insert into external db
$mydb->insert(
//name of external db table
'example-name',
//name of table columns and which fields to insert
//these are example fields
array(
'Salutation' => $field1,
'Surname' => $field2,
'Name' => $field3,
'Date of birth' => $field4,
'E-Mail' => $field5,
'Phone' => $field6,
'Street' => $field7,
'ZIP' => $field8,
'City' => $field9,
'Check 2' => $field10,
'Check 1' => $field11,
'number' => $field35,
'Data protection' => $field37,
),
//field formats: %s = string, %d = integer, %f = float
array(
'%s','%s','%s','%s','%s','%s','%s'
)
);
}
}
add_action('wpcf7_before_send_mail', 'wpcf7_send_to_external');
Alles anzeigen