APIs on Form Submission Handling

Hook: ipt_fsqm_hook_save_insert

Triggered when a new submission is stored in the eForm data table.

Hook Uses

The callback function is passed only one argument. A reference to the IPT_FSQM_Form_Elements_Data object that has called the hook.

[php]
/**
* Hook into ipt_fsqm_hook_save_insert
*
* @param object $data Object reference to IPT_FSQM_Form_Elements_Data
*/
function fsqm_hook_save_insert( $data ) {
// Do something with the data
// Perhaps throw a custom email
if ( $data->data->email != ” ) {
wp_mail( $data->data->email, __( ‘Here is a coupon for you’, ‘domain’ ), __( ‘Use code XYZ and avail great offers’, ‘domain’ ) );
}
}
add_action( ‘ipt_fsqm_hook_save_insert’, ‘fsqm_hook_save_insert’, 10, 1 );
[/php]

Source

Located in classes/class-ipt-fsqm-form-elements-data.php.

Hook: ipt_fsqm_hook_save_update

Triggered when an older submission is being updated.

Hook Uses

The callback gets one argument, a reference to the IPT_FSQM_Form_Elements_Data object that has called the hook. To know if the update was made by admin or user, check the objects admin_update and user_update variables.

[php]
/**
* Hook into ipt_fsqm_hook_save_update
*
* @param object $data Object reference to IPT_FSQM_Form_Elements_Data
*/
function fsqm_hook_save_update( $data ) {
// Do something
}
add_action( ‘ipt_fsqm_hook_save_update’, ‘fsqm_hook_save_update’, 10, 1 );
[/php]

Source

Located in classes/class-ipt-fsqm-form-elements-data.php.

Hook: ipt_fsqm_hook_save_success

Triggered when a database save of new/old submission is successful. It is triggered after the above two hooks and for both updates and new insertions.

Hook Uses

The callback gets one argument, a reference to the IPT_FSQM_Form_Elements_Data object that has called the hook. To know if it was an update check the doing_update variable. To know if the update was made by admin or user, check the objects admin_update and user_update variables.

[php]
/**
* Hook into ipt_fsqm_hook_save_success
*
* @param object $data Object reference to IPT_FSQM_Form_Elements_Data
*/
function fsqm_hook_save_success( $data ) {
// Do something
}
add_action( ‘ipt_fsqm_hook_save_success’, ‘fsqm_hook_save_update’, 10, 1 );
[/php]

Source

Located in classes/class-ipt-fsqm-form-elements-data.php.

Hook: ipt_fsqm_hook_save_error

Is triggered when any kind of error occurs (validation, data tampering etc) and eForm rejects to save the form.

Hook Uses

The callback gets one argument, a reference to the IPT_FSQM_Form_Elements_Data object that has called the hook. To know if it was an update check the doing_update variable. To know if the update was made by admin or user, check the objects admin_update and user_update variables.

[php]
/**
* Hook into ipt_fsqm_hook_save_error
*
* @param object $data Object reference to IPT_FSQM_Form_Elements_Data
*/
function fsqm_hook_save_error( $data ) {
// Do something
}
add_action( ‘ipt_fsqm_hook_save_error’, ‘fsqm_hook_save_update’, 10, 1 );
[/php]

Source

Located in classes/class-ipt-fsqm-form-elements-data.php.

Filter: ipt_fsqm_filter_data_errors

Used to modify the system generated errors during form submission on the server side.

Filter Uses

Filter passes two arguments. First one is an associative array of errors. If no errors were found, it would be empty. Second is the object reference of the IPT_FSQM_Form_Elements_Data that has called this filter.

[php]
/**
* Filters eForm Errors to force blacklist localhost submissions
* Filters into ipt_fsqm_filter_data_errors
*
* @param array $errors Associative array of errors
* @param object $obj Reference to IPT_FSQM_Form_Elements_Data object
*
* @return array
*/
function fsqm_blacklist_ips( $errors, $obj ) {
// Force an error
// If submitted from localhost IP
if ( in_array( $obj->data->ip, array( ‘127.0.0.1’, ‘::1’ ) ) ) {
// Add our own error
// Mind the structure
$errors[] = array(
‘id’ => ”, // ID of the HTML element where the error would appended. In this case it will be appended to the form
‘msgs’ => array( // An array of error messages
__( ‘Submission from localhost now allowed.’, ‘domain’ ),
),
);
}

return $errors;
}
add_filter( ‘ipt_fsqm_filter_data_errors’, ‘fsqm_blacklist_ips’, 10, 2 );
[/php]

Source

Located in classes/class-ipt-fsqm-form-elements-data.php.

Filter: ipt_fsqm_filter_save_error

Errors which would be returned to the client in case of validation and/or tampering and/or type mismatch.

Filter Uses

Filter passes two arguments. First is an associative array of errors which would be returned to the client. Second is the reference of IPT_FSQM_Form_Elements_Data object that has called this filter.

[php]
/**
* Filters eForm Errors to show a generalized error
* Filters into ipt_fsqm_filter_save_error
*
* @param array $errors Associative array of errors
* @param object $obj Reference to IPT_FSQM_Form_Elements_Data object
*
* @return array
*/
function fsqm_filter_save_errors( $errors, $obj ) {
// Do something with the errors
if ( $obj->settings[‘custom’][‘show_general_error’] == true ) {
// Let us just empty all the errors
// and show a general one instead
// Although not a good thing to do
// But still
$errors[‘errors’] = array(
‘id’ => ”,
‘msgs’ => array(
__( ‘Some errors have occured. Please review!’, ‘domain’ ),
),
);
}

return $errors;
}
add_filter( ‘ipt_fsqm_filter_save_error’, ‘fsqm_filter_save_errors’, 10, 2 );
[/php]

Source

Located in classes/class-ipt-fsqm-form-elements-data.php.

Filter: ipt_fsqm_user_email

Used to modify the user notification email.

Filter Uses

Filter passes two arguments. First one is the associative array of email variables. Second is the reference of IPT_FSQM_Form_Elements_Data object that has called this filter.

[php]
/**
* Modifies user email
* Filters ipt_fsqm_user_email
*
* @param array $user_email Associative array of email variables
* @param object $obj Object reference
*
* @return array
*/
function fsqm_modify_user_email( $user_email, $obj ) {
// The user email array is an associative one
// The key represents the email
// The value is an array with following datatype
/**
Array
(
[[email protected]] => Array
(
[title] => Email Message Title
[from] => Email From
[msgs] => Email Message
[smtp] => Whether to use SMTP (boolean)
[smtp_conf] => Array of SMTP configuration
[attachment] => Array of absolute file paths
)

)
*/
// We just add a nice attachment
$user_email[$obj->data->email][‘attachment’] = array( WP_CONTENT_DIR . ‘/uploads/file_to_attach.pdf’ );

return $user_email;
}
add_filter( ‘ipt_fsqm_user_email’, ‘fsqm_modify_user_email’, 10, 2 );
[/php]

Source

Located in classes/class-ipt-fsqm-form-elements-data.php.

Filter: ipt_fsqm_admin_email

Used to modify the admin notification email.

Filter Uses

Filter passes two arguments. First one is the associative array of email variables. Second is the reference of IPT_FSQM_Form_Elements_Data object that has called this filter.

[php]
/**
* Modifies admin email
* Filters ipt_fsqm_admin_email
*
* @param array $admin_email Associative array of email variables
* @param object $obj Object reference
*
* @return array
*/
function fsqm_modify_admin_email( $admin_email, $obj ) {
// Let us loop through all emails
// And add an attachment
// Also add a footer line
foreach ( $admin_email as $email => $edata ) {
$admin_email[$email][‘attachment’] = array( WP_CONTENT_DIR . ‘/uploads/file_to_attach.pdf’ );

if ( is_array( $admin_email[$email][‘msgs’] ) ) {
$admin_email[$email][‘msgs’][] = __( ‘Please check attached’, ‘domain’ );
} else {
$admin_email[$email][‘msgs’] .= ‘

‘ . __( ‘Please check attached’, ‘domain’ );
}
}

return $admin_email;
}
add_filter( ‘ipt_fsqm_admin_email’, ‘fsqm_modify_admin_email’, 10, 2 );
[/php]

Source

Located in classes/class-ipt-fsqm-form-elements-data.php.

Filter: ipt_fsqm_filter_save_success

Used to modify the success components being served to the client when a submission was successful.

Filter Uses

Filter passes two arguments. First is an associative array of variables being served to the client. Second is the reference of IPT_FSQM_Form_Elements_Data object that has called this filter.

[php]
/**
* Filter return json on successful save
*
* @param array $success_comp Associative array of success components
* @param object $obj Reference of parent object
*
* @return array
*/
function fsqm_filter_save_message( $success_comp, $obj ) {
// Let us modify the success components
// The data structure is as follows
/**
Array
(
[success] => 1
[components] => Array
(
[redirect] =>
[redirect_delay] => 0
[redirect_url] =>
[redirect_top] => 1
)

[msg] => Success message
)

*/
$success_comp[‘msg’] .= __( ‘You have won a coupon XYZ.’, ‘domain’ );
return $success_comp;
}
add_filter( ‘ipt_fsqm_filter_save_success’, ‘fsqm_filter_save_message’, 10, 2 );
[/php]

Source

Located in classes/class-ipt-fsqm-form-elements-data.php.

Filter: ipt_fsqm_form_elements_quick_preview_email_style

Used to modify inline CSS styles which are being applied to the summary table inside emails.

Filter Uses

Passes two arguments. First one is an array of styles which are being applied to different elements. Second is the reference of IPT_FSQM_Form_Elements_Data object that has called this filter.

[php]
/**
* Change email styling inline CSS
*
* @param array $email_styling Associative array of email styles
* @param object $obj Reference of parent object
*
* @return array
*/
function change_email_style( $email_styling, $obj ) {
// Change the email style inline CSS
// The structure of the array is as follows
/**
Array
(
[th] => css-prop: value; font-weight: bold;
[headth] => css-prop: value; font-weight: bold;
[footth] => css-prop: value; font-weight: bold;
[td] => css-prop: value; font-weight: bold;
[tdc] => css-prop: value; font-weight: bold;
[td_upload] => css-prop: value; font-weight: bold;
[icons] => css-prop: value; font-weight: bold;
[iconshead] => css-prop: value; font-weight: bold;
[th_icon] => css-prop: value; font-weight: bold;
[td_center] => css-prop: value; font-weight: bold;
[description] => css-prop: value; font-weight: bold;
[descriptionhead] => css-prop: value; font-weight: bold;
[table] => css-prop: value; font-weight: bold;
[inner_table] => css-prop: value; font-weight: bold;
[tr] => css-prop: value; font-weight: bold;
[headtr] => css-prop: value; font-weight: bold;
[foottr] => css-prop: value; font-weight: bold;
[thead] => css-prop: value; font-weight: bold;
[tfoot] => css-prop: value; font-weight: bold;
[tbody] => css-prop: value; font-weight: bold;
[logo_container] => css-prop: value; font-weight: bold;
[logo] => css-prop: value; font-weight: bold;
)

*/
// Change logo style
$email_styling[‘logo’] .= ‘background-color: #f3f3f3’;

return $email_styling;
}
add_filter( ‘ipt_fsqm_form_elements_quick_preview_email_style’, ‘change_email_style’, 10, 2 );
[/php]

Source

Located in classes/class-ipt-fsqm-form-elements-data.php.

Filter: ipt_fsqm_filter_social_buttons

Used to modify social sharing.

Filter Uses

Passes 5 arguments.

  • $return: The HTML string of social buttons that would be appended at the end of success message.
  • $html: An associative array of different social sharing sites and their configuration variables.
  • $settings: Form settings for social sharing.
  • $form_id: Form ID.
  • $data_id: Data ID.

[php]
/**
* Change social sharing buttons
*
* @param string $return HTML string
* @param array $html Array of social service and share URL
* @param array $settings Form settings for social sharing
* @param integer $form_id Form ID
* @param integer $data_id Data ID
*
* @return string
*/
function change_social_share( $return, $html, $settings, $form_id, $data_id ) {
// Let us iterate through $html
// and recreate $return
// But we do not want facebook
// So we will delete it in the process
$return = ”;
foreach ( $html as $key => $val ) {
// Do nothing if it is a facebook button
if ( $key == ‘facebook_url’ ) {
continue;
}
$return .= ‘<a href="’ . ${$key} . ‘" target="_blank">’ . $val . ‘</a>&nbsp;&nbsp;’;
}

return $return;
}
add_filter( ‘ipt_fsqm_filter_social_buttons’, ‘change_social_share’, 10, 5 );
[/php]

Source

Located in classes/class-ipt-fsqm-form-elements-data.php.

Filter: ipt_fsqm_form_progress_buttons

Used to modify the progress buttons of a form.

Filter Uses

Passes two parameters, first an associative array defining buttons and their configurations. Second is the reference of IPT_FSQM_Form_Elements_Front object that has called this filter.

[php]
/**
* Add a custom button near progress buttons
* for multipaged/tabbed forms
*
* @param array $buttons An associative array of buttons with configuration values
*
* @return array
*/
function fsqm_add_progress_button( $buttons ) {
// Add a navigate to the first tab button
// This will just add the button to the form
// Making it interactive would still require putting some JS
$buttons[] = array(
‘text’ => ‘<i class="ipt-icomoon-step-backward"></i>’,
‘name’ => ”,
‘size’ => ‘small’,
‘style’ => ‘primary’,
‘state’ => ‘normal’,
‘classes’ => array( ‘ipt_fsqm_form_button_first_tab ipt_uif_tooltip’ ),
‘type’ => ‘reset’,
‘data’ => array(),
‘atts’ => array(
‘title’ => __( ‘Navigate to first tab’, ‘domain’ ),
),
);
return $buttons;
}
add_filter( ‘ipt_fsqm_form_progress_buttons’, ‘fsqm_add_progress_button’, 10, 1 );
[/php]

Source

Located in classes/class-ipt-fsqm-form-elements-front.php.

Swashata has written 257 articles

Hi there, I am the Lead Developer at WPQuark.com. I love to create something beautiful for WordPress and here I write about how to use them. When I am not working, usually I am doing a number of other creative things ;).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.