special offer desktop
menu-icon
Bit Assist Menu Icon
Estimated reading: 5 minutes 383 views

PHP Action Hooks – Bit Form

The Bit Forms plugin provides several PHP action hooks that allow you to customize and extend its functionality. These action hooks enable you to perform specific tasks at different stages of the form submission process. Example: bitform_submit_success

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

  1. bitform_submit_success
  2. bitform_validation_error
  3. bitform_submit_error
  4. bitform_save_entry
  5. bitform_save_entry_error
  6. bitform_update_entry
  7. bitform_update_entry_error
  8. bitform_after_update_entry_success

bitform_submit_success

Description

This action hook is fired after the form data has been saved to the database. It can be used to execute additional actions or integrations based on the submitted form data.

do_action('bitform_submit_success', $formId, $entryId, $formData);

Usage

The following would apply to all forms:

add_action('bitform_submit_success', 'submission_success', 10, 3);
function submission_success($formId, $entryId, $formData)
{
// Write Your Code Here
}

Parameters

  • $formId (integer) Form ID
  • $entryId (integer) Entry ID of this response
  • $formData (array) Entry Response as key value pairs array as input name as array key

bitform_validation_error

Description

This action hook is fired when an error occurs during form submission.

do_action('bitform_validation_error', $formId, $isValidated);

Usage

The following would apply to all forms:

add_action('bitform_validation_error', 'field_validation_fail', 10, 2);
function field_validation_fail($formId, $isValidated)
{
// Write Your Code Here
}

Parameters

  • $formId (integer) Form ID
  • $isValidated (boolean) True or False

bitform_submit_error

Description

This action hook is fired when an error occurs during form submission.

do_action('bitform_submit_error', $formId, $isSubmitted);

Usage

The following would apply to all forms:

add_action('bitform_submit_error', 'form_validation', 10, 2);
function form_validation($formId, $isSubmitted)
{
// Write Your Code Here
}

Parameters

  • $formId (integer) Form ID
  • $isValidated (boolean) True or False

bitform_save_entry

Description:

This action hook fires before the form entry is saved to the database. This action hook is called when submitted form. The action hook receives the submitted data and form ID as a parameter.

do_action('bitform_save_entry', $submitted_data, $this->form_id);

Usage:

The following example shows how to use this action hook.

add_action('bitform_save_entry', 'your_function_name', 10, 3);

function your_function_name($submitted_data, $form_id) {
    // Do something here
}

Parameters:

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

bitform_save_entry_error

Description:

This action hook fires when the form entry is not saved to the database and throw error. This action hook is called when submitted form for save entry. The action hook receives this class instance(object), the submitted data, and form ID as a parameter.

do_action('bitform_save_entry_error', $this, $submitted_data, $this->form_id);

Usage:

The following example shows how to use this action hook.

add_action('bitform_save_entry_error', 'your_function_name', 10, 3);

function your_function_name($formManager, $submitted_data, $form_id) {
    // Do something here
}

Parameters:

  • $formManager (object) (required) The form manager class instance.
  • $submitted_data (array) (required) The submitted data as an array.
  • $form_id (int) (required) The form ID.
$submission_data = [
    // fieldKey => value
    'b1-1' => 'value1',
    'b1-2' => 'value2',
]

bitform_update_entry

Description:

This action hook fires before the form entry is updated to the database. This action hook is called when update form entry. The action hook receives this class instance, the updated data, form ID, and entry ID as a parameter.

do_action('bitform_update_entry', $this, $updatedValue, $formID, $entryID);

Usage:

The following example shows how to use this action hook.

add_action('bitform_update_entry', 'your_function_name', 10, 3);

function your_function_name($formManager, $updatedValue, $formID, $entryID) {
    // Do something here
}

Parameters:

  • $formManager (object) (required) The form manager class instance.
  • $updatedValue (array) (required) The updated data as an array key as field key and value pair.
  • $form_id (int) (required) The form ID. $entry_id (int) (required) The entry ID.
$updatedValue = [
    'b1-1' => 'value1',
    'b1-2' => 'value2',
]

bitform_update_entry_error

Description:

This action hook fires when the form entry is not updated to the database and throw error. This action hook is called when update form entry. The action hook receives this class instance, the updated data, form entry meta update status wp error and form ID as a parameter.

do_action('bitform_update_entry_error', $this, $updatedValue, $formEntryMetaUpdateStatus, $formID);

Usage:

The following example shows how to use this action hook.

add_action('bitform_update_entry_error', 'your_function_name', 10, 3);

function your_function_name($formManager, $updatedValue, $formEntryMetaUpdateStatus, $formID) {
    // Do something here
}

Parameters:

  • $formManager (object) (required) The form manager class instance.
  • $updatedValue (array) (required) The updated data as an array key as field key and value pair.
  • $formEntryMetaUpdateStatus WpError (required) The form entry meta update status.
  • $form_id (int) (required) The form ID.
$updatedValue = [
    'b1-1' => 'value1',
    'b1-2' => 'value2',
]

bitform_after_update_entry_success

Description:

This action hook fires after the form entry is updated to the database. This action hook is called when updated data successfully in database. The action hook receives this class instance, the updated data, form ID, and entry ID as a parameter.

do_action('bitform_after_update_entry_success', $this, $updatedValue, $formID, $entryID);

Usage:

The following example shows how to use this action hook.

add_action('bitform_after_update_entry_success', 'your_function_name', 10, 3);

function your_function_name($formManager, $updatedValue, $formID, $entryID) {
    // Do something here
}

Parameters:

  • $formManager (object) (required) The form manager class instance.
  • $updatedValue (array) (required) The updated data as an array key as field key and value pair.
  • $formID (int) (required) The form ID.
  • $entryID (int) (required) The entry ID.
$updatedValue = [
    'b1-1' => 'value1',
    'b1-2' => 'value2',
]
Share this Doc

PHP Action Hooks

Or copy link

CONTENTS