Description #
This filter is available just before the entry is inserted into the database and a submission. If you want to change response data then you should use fluentform/insert_response_data filter hook.
apply_filters('fluentform/filter_insert_data', $response);
Usage #
The following would apply to all forms:
add_filter('fluentform/filter_insert_data', 'your_custom_code_before_insert_to_database_function', 10, 1);
function your_custom_code_before_insert_to_database_function($response)
{
// DO your stuffs here
return $response;
}
The following would apply to a specific form id 5:
add_filter('fluentform/filter_insert_data', 'your_custom_code_before_insert_to_database_function', 10, 1);
function your_custom_code_before_insert_to_database_function($response)
{
if($formId != 5) {
return;
}
// DO your stuffs here
return $response;
}
Parameters #
- $response (array) Submission Data Array
$response = [
'form_id' => 5, // Form ID
'serial_number' => 1, // Numeric Serial Number
'response' => json_encode($response), // The submitted response as JSON
'source_url' => $source_url, // source url eg: https://domain.com/contact-form
'user_id' => 1, // current user id
'browser' => 'Chrome',
'device' => 'ipad',
'ip' => '127.0.0.1',
'created_at' => '2019-12-31 23:12:34',
'updated_at' => '2019-12-31 23:12:34'
];
$response = apply_filters('fluentform/filter_insert_data', $response);
Placement #
This code should be placed in the functions.php file of your active theme.
Source Code #
This filter is located in FluentForm\App\Services\Form\SubmissionHandlerService -> prepareInsertData($formData = false)