Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter maahfuz

    (@maahfuz)

    Thanks Patrick Freitas.
    I have used your code but it still doesn’t save data to my database table. Could you please give an example how can I save this data to my database table. Suppose the table name is wp_form_data

    Best Regards
    maahfuz

    Thread Starter maahfuz

    (@maahfuz)

    I have used following code in my functions.php. But it doesn’t work.

    function handle_forminator_form_submission($response, $form_id, $data) {
    
    ? ? ? ? ? ? // Check if the form submission was successful
    
    ? ? ? ? ? ? error_log('Forminator form submission triggered');
    
    ? ? ? ? ? ? if ($response['success']) {
    
    ? ? ? ? ? ? ? ? // Get submitted form data
    
    ? ? ? ? ? ? ? ? $form_data = $data['data'];
    
    ? ? ? ? ? ? ? ? // Extract data from Forminator form
    
    ? ? ? ? ? ? ? ? $text_1 = isset($form_data['text-1']) ? sanitize_text_field($form_data['text-1']) : '';
    
    ? ? ? ? ? ? ? ? $text_2 = isset($form_data['text-2']) ? sanitize_text_field($form_data['text-2']) : '';
    
    ? ? ? ? ? ? ? ? // Insert form data into custom database table
    
    ? ? ? ? ? ? ? ? global $wpdb;
    
    ? ? ? ? ? ? ? ? $table_name = $wpdb->prefix . 'form_new'; // Replace with your custom table name
    
    ? ? ? ? ? ? ? ? $wpdb->insert(
    
    ? ? ? ? ? ? ? ? ? ? $table_name,
    
    ? ? ? ? ? ? ? ? ? ? array(
    
    ? ? ? ? ? ? ? ? ? ? ? ? 'text_1' => $text_1,
    
    ? ? ? ? ? ? ? ? ? ? ? ? 'text_2' => $text_2,
    
    ? ? ? ? ? ? ? ? ? ? ? ? // Add more fields as needed
    
    ? ? ? ? ? ? ? ? ? ? )
    
    ? ? ? ? ? ? ? ? );
    
    ? ? ? ? ? ? }
    
    ? ? ? ? }
Viewing 2 replies - 1 through 2 (of 2 total)