I have tried to save Wpforms entries into my own database, and used the action hook 'wpforms_process_entry_save' to do so. But i got this error message which indicate,I think,that parameters passed into my function doesn't much the arguments that the wpforms_process_entry_save hook expect to receive. So, how can I retrieve ($field, $form_data, $entry_id values) and passe them correctly into wpforms hook?

 add_action('wpforms_process_entry_save', array(self::$instance, 'process_entry( $fields, $id )', 5, 4));

function process_entry($form_fields, $entry, $form_data, $entry_id)
         {

             global $wpdb;
             $form_id = $form_data['id'];
             $entry_data = array(
                 'form_id' => $form_id,
                 'status' => 'publish',
                 'referer' => $_SERVER['HTTP_REFERER'],
                 'date_created' => current_time('mysql')
             );

             // Insert into wpforms_entries custom table.
             $success = $wpdb->insert($wpdb->prefix . 'wpforms_entries', $entry_data);
             $entry_id = $wpdb->insert_id;

             // Create meta data.
             if ($entry_id) {
                 foreach ($form_fields as $field) {
                     $field = apply_filters('wpforms_process_entry_field', $field, $form_data, $entry_id);
                     if (isset($field['value']) && '' !== $field['value']) {
                         $field_value = is_array($field['value']) ? serialize($field['value']) : $field['value'];
                         $entry_metadata = array(
                             'entry_id' => $entry_id,
                             'meta_key' => $field['name'],
                             'meta_value' => $field_value,
                         );
                         // Insert entry meta.
                         $wpdb->insert($wpdb->prefix . 'wpforms_entrymeta', $entry_metadata);
                     }
                 }
             }
         }

I have tried to use the function process_entry without passing any argments, but i got an error.

0

There are 0 best solutions below