WordPress | Specify input fields to be saved by cf7 [closed]


I’m trying to be able to do a very custom thing, which is to alter the code of a plugin to suit my needs.

I needed to save all forms submitted through the cf7 plugin for wordpress in my database.

I found a plugin that fits the bill and its name is: Advanced CF7 DB

Testing the behavior of this plugin which, upon activation, creates a table named {prefix}_cf7_vdata_entry, regardless of how many inputs make up the form, saves them all in the value table

image of db:
enter image description here

looking in the plugin code in the file includes> vsz_cf7_db_function.php at line 70, I find the insert query

//Insert current form submission time in database
$time = date('Y-m-d H:i:s');
$wpdb->query($wpdb->prepare('INSERT INTO '.VSZ_CF7_DATA_TABLE_NAME.'(`created`) VALUES (%s)', $time));
//Get last inserted id
$data_id = $wpdb->insert_id;

//Insert form values in custom data entry table
if(!empty($cf7_id) && !empty($data_id)){
    //Get not inserted fields value list
    $cf7d_no_save_fields = vsz_cf7_no_save_fields();
    foreach ($contact_form->posted_data as $k => $v) {
        //Check not inserted fields name in array or not
        if(in_array($k, $cf7d_no_save_fields)) {
            //If value is check box and radio button value then creaye single string
                $v = implode("n", $v);
            $k = htmlspecialchars($k);
            $v = htmlspecialchars($v);
            $wpdb->query($wpdb->prepare('INSERT INTO '.VSZ_CF7_DATA_ENTRY_TABLE_NAME.'(`cf7_id`, `data_id`, `name`, `value`) VALUES (%d,%d,%s,%s)', $cf7_id, $data_id, $k, $v));
    //Add action for customize process after insert value in data base
    do_action('vsz_cf7_after_insert_db', $contact_form, $cf7_id, $data_id);

I was wondering having constant inputs in my form, let’s admit the fact that I create an additional table after: value and call it: surname and inside surname I want to insert what in the picture is the value of COGNOME

the plugin reasons that in the name table, it inserts the name of the input fields that are created in cf7, and in value, it inserts the values ​​that the user fills in these fields.

If I created an additional table called surname, I would like it to insert the input value called surname into that table.

Then enter the values ​​of the form fields specifying the name of the field and do not include them all in name


let’s assume I have an input name called surname

a custom table named surname

and I tell him insert in surname the value that comes from the specific input surname

user14633289 2 months 0 Answers 10 views 0

Leave an answer