Black Friday
Super Deal
bit form 74% Off
Offer ends in:
00

days day

00

hours hour

00

Mins Min

00

Secs Sec

Estimated reading: 17 minutes 1129 views

PHP Filter Hooks – Bit Form

Here are some of the main Bit Forms PHP filter hooks:​

  1. bitform_filter_format_submitted_data
  2. bitform_filter_save_form_entry
  3. bitform_filter_user_details
  4. bitform_filter_save_entry_user_details
  5. bitform_filter_return_submit_success
  6. bitform_filter_submission_log_data
  7. bitform_filter_update_form_entry
  8. bitform_filter_update_entry_user_details
  9. bitform_filter_return_edit_success
  10. bitform_filter_before_workflow_onload_fields
  11. bitform_filter_after_workflow_onload_fields
  12. bitform_filter_wp_user_auth_response
  13. bitform_filter_form_validation
  14. bitform_filter_integration_run_failure_message
  15. bitform_filter_restriction_one_per_ip_message
  16. bit_form_upload_disallowed_mimes
  17. bit_form_upload_denied_extensions
  18. bit_form_upload_allow_file
  19. bitform_filter_pdf_body
  20. bitform_filter_pdf_filename
  21. bitform_filter_email_subject
  22. bitform_filter_email_body

bitform_filter_format_submitted_data

Description:

If you want to modify the submitted data before it is saved or update to the database, you can use this filter. The filter receives the submitted data as an array and the form ID as a parameter.

apply_filters('bitform_filter_format_submitted_data', $submitted_data, $this->form_id);

Usage:

The following example shows how to modify the submitted data before it is saved to the database.

add_filter('bitform_filter_format_submitted_data', 'your_function_name', 10, 2);

function your_function_name($submittedData, $formId) {
    // Modify the submitted data here
    return $submittedData;
}

Parameters:

  • $submittedData (array) (required) The submitted data as an array.
  • $formId (int) (required) The form ID.
$submission_data = [
    // fieldKey => value
    'b1-1' => 'value1',
    'b1-2' => 'value2',
]

bitform_filter_save_form_entry

Description:

If you want to modify the form entry before it is saved to the database, you can use this filter. The filter receives the submitted data as an array and the form ID as a parameter.

apply_filters('bitform_filter_save_form_entry', $submitted_data, $this->form_id);

Usage:

The following example shows how to modify the form entry before it is saved to the database.

add_filter('bitform_filter_save_form_entry', 'your_function_name', 10, 2);

function your_function_name($submittedData, $formId) {
    // Modify the form entry here
    return $submittedData;
}

Parameters:

  • $submittedData (array) (required) The submitted data as an array.
  • $formId (int) (required) The form ID.
$submission_data = [
    // fieldKey => value
    'b1-1' => 'value1',
    'b1-2' => 'value2',
]

bitform_filter_user_details

Description:

This filter available just modify the user details before it is save or update to the database, you can use this filter. The filter receives the user details as an array and the form ID as a parameter.

apply_filters('bitform_filter_user_details', $user_details, $this->form_id);

Usage:

The following example shows how to modify the user details before it is saved to the database.

add_filter('bitform_filter_user_details', 'your_function_name', 10, 2);

function your_function_name($userDetails, $formId) {
    // Modify the user details here
    return $userDetails;
}

Parameters:

  • $userDetails (array) (required) The user details as an array.
  • $formId (int) (required) The form ID.
$user_details = [
    'ip' => 'user ip',
    'device' => 'user device',
    'id' => get_current_user_id(),
    'page' => 'user page',
    'time' => current_time('mysql'),
];

bitform_filter_save_entry_user_details

Description:

If you want to modify the user details before it is saved to the database, you can use this filter. The filter receives the user details as an array and the form ID as a parameter.

apply_filters('bitform_filter_save_entry_user_details', $user_details, $this->form_id);

Usage:

The following example shows how to modify the user details.

add_filter('bitform_filter_save_entry_user_details', 'your_function_name', 10, 2);

function your_function_name($userDetails, $formId) {
    // Modify the user details here
    return $userDetails;
}

Parameters:

  • $userDetails (array) (required) The user details as an array.
  • $formId (int) (required) The form ID.
$user_details = [
    'ip' => 'user ip',
    'device' => 'user device',
    'id' => get_current_user_id(),
    'page' => 'user page',
    'time' => current_time('mysql'),
];

bitform_filter_return_submit_success

Description:

If you want to modify the Workflow return on submission before it is returned to the user, you can use this filter. The filter receives the wWork Flow Returned On Submit as a array and the form ID as a parameter.

apply_filters('bitform_filter_return_submit_success', $workFlowreturnedOnSubmit, $this->form_id);

Usage:

The following example shows how to modify the success message.

add_filter('bitform_filter_return_submit_success', 'your_function_name', 10, 2);

function your_function_name($workFlowreturnedOnSubmit, $formId) {
    // Modify the success message here
    return $workFlowreturnedOnSubmit;
}

Parameters:

  • $workFlowreturnedOnSubmit (array) (required) The work flow returned on submit as an array.
  • $formId (int) (required) The form ID.
$workFlowreturnedOnSubmit = [
    'fields' => [
        'b1-1' => 'value1',
        'b1-2' => 'value2',
    ],
    'message' => 'Form Submitted Successfully',
    'msg_id' => 0,
    'dflt_message' => 1,
    'redirectPage' => 'redirectPage url',
    'triggerData' => [
        'mail' => array(),
        'integrations' => array(),
        'dblOptin' => array(),
        'logID' => 0,
    ],
    'cron' => 1,
    'entry_id' => 0,
];

bitform_filter_submission_log_data

Description:

This filter is available just use to modify the submission log data before it is saved to the database. The filter receives the submission log data as an array, form ID, and the type as a parameter.

apply_filters('bitform_filter_submission_log_data', $submissionLogData, $this->form_id, $type);

Usage:

The following example shows how to modify the submission log data before it is saved to the database.

add_filter('bitform_filter_submission_log_data', 'your_function_name', 10, 3);

function your_function_name($submissionLogData, $formId, $type) {
    // Modify the submission log data here
    return $submissionLogData;
}

Parameters:

  • $submissionLogData (array) (required) The submission log data as an array.
  • $formId (int) (required) The form ID.
  • $type (string) (required) The type as create or update submission log.
$submissionLogData = [
    'user_id'       => 'user id',
    'action_type'   => 'type', // create, update
    'log_type'      => 'entry',
    'ip'            => 'user ip',
    'form_entry_id' => 'entry_id',
    'content'       => null,
    'form_id'       => 'form id',
    'created_at'    => current_time('mysql'),
];

bitform_filter_update_form_entry

Description:

If you want to modify the form entry before it is updated to the database, you can use this filter. The filter receives the updated data as an array and the form ID as a parameter.

apply_filters('bitform_filter_update_form_entry', $updatedValue, $this->form_id);

Usage:

The following example shows how to modify the form entry before it is updated to the database.

add_filter('bitform_filter_update_form_entry', 'your_function_name', 10, 2);

function your_function_name($updatedValue, $formId) {
    // Modify the form entry here
    return $updatedValue;
}

Parameters:

  • $updatedValue (array) (required) The updated data as an array key as field key and value pair.
  • $formId (int) (required) The form ID.
$updatedValue = [
    'b1-1' => 'value1',
    'b1-2' => 'value2',
]

bitform_filter_update_entry_user_details

Description:

This filter is available just use to modify the user details before it is updated to the database. This filter called when update form entry. The filter receives the user details as an array and the form ID as a parameter.

apply_filters('bitform_filter_update_entry_user_details', $user_details, $this->form_id);

Usage:

The following example shows how to modify the user details before it is updated to the database.

add_filter('bitform_filter_update_entry_user_details', 'your_function_name', 10, 2);

function your_function_name($userDetails, $formId) {
    // Modify the user details here
    return $userDetails;
}

Parameters:

  • $userDetails (array) (required) The user details as an array.
  • $formId (int) (required) The form ID.
$user_details = [
    'ip' => 'user ip',
    'device' => 'user device',
    'id' => get_current_user_id(),
    'page' => 'user page',
    'time' => current_time('mysql'),
];

bitform_filter_return_edit_success

Description:

This filter is available just use to modify the Workflow return on edit form entry success it is returned to the edit success. This filter is called when Update Form Entry. The filter receives the Workflow Returned On Submit as a array and the form ID as a parameter.

apply_filters('bitform_filter_return_edit_success', $workFlowreturnedOnSubmit, $this->form_id);

Usage:

The following example shows how to modify the Workflow return on edit form entry success.

add_filter('bitform_filter_return_edit_success', 'your_function_name', 10, 2);

function your_function_name($workFlowreturnedOnSubmit, $formId) {
    // Modify the success message here
    return $workFlowreturnedOnSubmit;
}

Parameters:

  • $workFlowreturnedOnSubmit (array) (required) The work flow returned on submit as an array.
  • $formId (int) (required) The form ID.
$workFlowreturnedOnSubmit = [
    'fields' => [
        'b1-1' => 'value1',
        'b1-2' => 'value2',
    ],
    'message' => 'Form Submitted Successfully',
    'msg_id' => 0,
    'dflt_message' => 1,
    'redirectPage' => 'redirectPage url',
    'triggerData' => [
        'mail' => array(),
        'integrations' => array(),
        'dblOptin' => array(),
        'logID' => 0,
    ],
    'cron' => 1,
    'entry_id' => 0,
];

bitform_filter_before_workflow_onload_fields

Description:

If you want to modify the fields before the workflow onload, you can use this filter. The filter receives the fields as an array and the form ID as a parameter.

apply_filters('bitform_filter_before_workflow_onload_fields', $fields, $formID);

Usage:

The following example shows how to modify the submitted data before it is saved to the database.

add_filter('bitform_filter_before_workflow_onload_fields', 'your_function_name', 10, 2);

function your_function_name($fields, $formId) {
    // Modify the fields here
    return $fields;
}

Parameters:

  • $fields (object) (required) The fields as an object.
  • $formID (int) (required) The form ID.

bitform_filter_after_workflow_onload_fields

Description:

If you want to modify the fields after the workflow onload, you can use this filter. The filter receives the fields as an array and the form ID as a parameter.

apply_filters('bitform_filter_after_workflow_onload_fields', $fields, $formID);

Usage:

The following example shows how to modify the submitted data before it is saved to the database.

add_filter('bitform_filter_after_workflow_onload_fields', 'your_function_name', 10, 2);

function your_function_name($fields, $formId) {
    // Modify the fields here
    return $fields;
}

Parameters:

  • $fields (array) (required) The fields as an array.
  • $formID (int) (required) The form ID.

bitform_filter_wp_user_auth_response

Description:

If you want to modify the response of the WordPress user authentication, you can use this filter. The filter receives the response as an array, the submitted data as an array, and the parameter as a parameter.

apply_filters('bitform_filter_wp_user_auth_response', $result, $form_id, $_POST, $parameter)

Usage:

The following example shows how to modify the response of the WordPress user authentication.

add_filter('bitform_filter_wp_user_auth_response', 'your_function_name', 10, 4);
function your_function_name($result, $formId, $submittedData, $urlParameter) {
    // Modify the response here
    return $result;
}

Parameters:

  • $result (array) (required) The response of the WordPress user authentication as an array.
  • $formId (int) (required)
  • $submittedData(array) (required) The submitted data as an array.
  • $urlParameter (array) (required) The parameter.

bitform_filter_form_validation

Description:

If you want to modify the form validation before it is saved to the database, you can use this filter. The filter receives the form validation as a boolean and the form ID as a parameter.

apply_filters('bitform_filter_form_validation', $validated, $this->_form_id);

Usage:

The following example shows how to modify the form validation before it is saved to the database.

add_filter('bitform_filter_form_validation', 'your_function_name', 10, 2);
function your_function_name($validated, $form_id) {
// Modify the form validation here
return $validated;
}

Parameters:

  • $validated (boolean) (required) The form validation as a boolean.
  • $form_id (int) (required) The form ID.

bitform_filter_integration_run_failure_message

Description:

If you want to modify the integration run failure message before it is returned to the user, you can use this filter. The filter receives the integration run failure message as a string, integration ID, and form ID as a parameter.

apply_filters('bitform_filter_integration_run_failure_message', $messages, $integrationID, $formID);

Usage:

The following example shows how to modify the integration run failure message.

add_filter('bitform_filter_integration_run_failure_message', 'your_function_name', 10, 3);
function your_function_name($message, $integrationID, $formID) {
// Modify the integration run failure message here
return $message;
}

Parameters:

  • $message (string) (required) The integration run failure message as a string.
  • $integrationID (int) (required) The integration ID.
  • $formID (int) (required) The form ID.

bitform_filter_restriction_one_per_ip_message

Description:

This filter allows you to change the message displayed when a user tries to submit a form more than once from the same IP address.

apply_filters('bitform_filter_restriction_one_per_ip_message', $onePerIp, $this->form_id);

Usage:

  • Implementation of the filter to change the restriction message
  • This function modifies the message shown when a user attempts to submit a form more than once from the same IP address.
add_filter('bitform_filter_restriction_one_per_ip_message', 'change_bitform_restriction_message', 10, 2);

function change_bitform_restriction_message($restrictionMessage, $formId) {
	
1. You can customize the restriction message here
2. This message will be displayed when a user tries to submit the form again from the same IP address
3. You can also use the $formId if you want to customize the message based on the specific form
4. For example, you could use different messages for different forms by checking the $formId
5. Here, we are simply returning a static message, but you can modify it as needed
6. Example: if ($formId == 123) { $restrictionMessage = 'Custom message for form 123'; }
7. Example: if ($formId == 456) { $restrictionMessage = 'Custom message for form 456'; }

$restrictionMessage = 'You are already submitted this form.'; // modify your message 

    return $restrictionMessage;
}

bit_form_upload_disallowed_mimes

This filter allows developers to modify the list of disallowed MIME types. It’s useful when you want to block certain file types globally, such as executables or other potentially dangerous content.

Usage:

add_filter( 'bit_form_upload_disallowed_mimes', 'custom_disallowed_mimes' );

function custom_disallowed_mimes( $disallowedMimes ) {
    // Add custom MIME types to disallow
    $disallowedMimes[] = 'application/x-php';  // Example: Block PHP files
    return $disallowedMimes;
}

Parameters:

  • $disallowedMimes (array): List of MIME types that are disallowed. Default disallowed types include:
[
    'application/x-php', 'text/x-php', 'application/x-msdownload',
    'application/x-msdos-program', 'application/x-sh', 'application/x-csh',
    'text/x-shellscript', 'application/java-archive'
]

Return Value:

  • (array): The modified list of disallowed MIME types.

bit_form_upload_denied_extensions

This filter lets you add or remove file extensions that are disallowed for upload. You can use this to block specific extensions, such as .php, .exe, or others, based on your security needs.

Usage:

add_filter( 'bit_form_upload_denied_extensions', 'custom_denied_extensions' );

function custom_denied_extensions( $denyExt ) {
    // Add extensions to block (e.g., block .exe files)
    $denyExt[] = 'exe';
    return $denyExt;
}

Parameters:

  • $denyExt (array): List of file extensions that are denied. Default list includes:
['php', 'phtml', 'phar', 'htaccess', 'html', 'js', 'exe', 'sh', 'bat', 'cmd']

Return Value:

  • (array): The modified list of denied file extensions.

bit_form_upload_allow_file

This is a final decision filter that lets you apply your custom logic to determine if a file should be accepted or rejected based on the file name, extension, MIME type, and more. It allows the highest level of customization, giving you full control over whether a file is accepted by the plugin.

Usage:

add_filter( 'bit_form_upload_allow_file', 'custom_allow_file_logic', 10, 2 );

function custom_allow_file_logic( $allow, $file_info ) {
    // Custom logic to accept or reject files based on custom criteria
    if ( 'example.jpg' === $file_info['file_name'] ) {
        return false;  // Reject "example.jpg" files
    }

    // Allow all other files
    return $allow;
}

Parameters:

  • $allow (bool): The current decision (true if the file is allowed, false if rejected).
  • $file_info (array): Information about the file being uploaded, which includes:
    • ‘file_name’ (string): The name of the file.
    • ‘extension’ (string): The file extension.
    • ‘detected_mime’ (string): The detected MIME type.
    • ‘wp_ext’ (string): The extension detected by wp_check_filetype_and_ext().
    • ‘wp_type’ (string): The MIME type detected by wp_check_filetype_and_ext().
    • ‘allow_exts’ (array): The list of allowed extensions.
    • ‘allow_mimes’ (array): The list of allowed MIME types.
    • ‘has_allowlist’ (bool): Whether an allowlist was provided.

Return Value:

  • (bool): Return true to allow the file, or false to reject it.

bitform_filter_pdf_body

Purpose: Modify the content of the generated PDF body before it is sent out.
Use Case: You can use this filter to add custom content to the PDF, such as adding a footer, inserting dynamic content, or applying custom formatting.

Usage:

add_filter('bitform_filter_pdf_body', function ($body, $ctx) {
  // Add a custom footer to the PDF body
  $footer = '<p style="font-size:12px;color:#666;">Generated by Bit Forms on ' . date('Y-m-d') . '</p>';
  return $body . $footer;
}, 10, 2);

Parameters:

  • $body (string) – The body of the PDF, already populated with field values.
  • $ctx (array) – An associative array containing context data:
    • ‘form_id’ (int) – The ID of the form.
    • ‘entry_id’ (int) – The ID of the form entry.
    • ‘field_values’ (array) – The field values submitted in the form.
    • ‘pdf_setting’ (object) – The PDF settings retrieved from the template.
    • ‘template’ (object) – The PDF template object.

bitform_filter_pdf_filename

Purpose: Modify the filename of the generated PDF before it is saved.
Use Case: You can use this filter to dynamically change the filename, for example, to prepend the form ID or append a timestamp.

Usage:

add_filter('bitform_filter_pdf_filename', function ($filename, $ctx) {
  // Prepend the form ID and current date to the filename
  $date = date('Ymd');
  return 'Form-' . $ctx['form_id'] . '-' . $date . '-' . $filename;
}, 10, 2);

Parameters:

  • $filename (string) – The generated filename for the PDF.
  • $ctx (array) – An associative array containing context data:
    • ‘form_id’ (int) – The ID of the form.
    • ‘entry_id’ (int) – The ID of the form entry.
    • ‘field_values’ (array) – The field values submitted in the form.
    • ‘pdf_setting’ (object) – The PDF settings retrieved from the template.
    • ‘template’ (object) – The PDF template object.

bitform_filter_email_subject

Purpose: Modify the subject of the email that is sent.
Use Case: You can use this filter to dynamically change the email subject based on form field values, form IDs, or other context data.

Usage:

add_filter('bitform_filter_email_subject', function ($subject, $ctx) {
  // Add the form ID to the email subject
  return '[Form ' . $ctx['form_id'] . '] ' . $subject;
}, 10, 2);

Parameters:

  • $subject (string) – The subject line of the email.
  • $ctx (array) – An associative array containing context data:
    • ‘form_id’ (int) – The ID of the form.
    • ‘entry_id’ (int) – The ID of the form entry.
    • ‘field_values’ (array) – The field values submitted in the form.
    • ‘template’ (object) – The email template object.
    • ‘is_double_optin’ (bool) – A flag indicating whether double opt-in is enabled.

bitform_filter_email_body

Purpose: Modify the body content of the email before it is sent.
Use Case: You can use this filter to customize the email body, such as adding dynamic content, modifying existing placeholders, or adding new HTML elements.

Usage

add_filter('bitform_filter_email_body', function ($body, $ctx) {
  // Add a personalized greeting to the email body
  $firstName = $ctx['field_values']['first_name'] ?? 'User';
  return '<p>Hi ' . esc_html($firstName) . ',</p>' . $body;
}, 10, 2);

Parameters:

  • $body (string) – The body of the email, already populated with field values.
  • $ctx (array) – An associative array containing context data:
    • ‘form_id’ (int) – The ID of the form.
    • ‘entry_id’ (int) – The ID of the form entry.
    • ‘field_values’ (array) – The field values submitted in the form.
    • ‘template’ (object) – The email template object.
    • ‘is_double_optin’ (bool) – A flag indicating whether double opt-in is enabled.

Share this Doc

PHP Filter Hooks

Or copy link

CONTENTS