Filter/Action Hooks

If you need or want to modify the Notification message before it is sent, use the following example WP filter:

// string $message, body of message containing field ID: data
// array $fields, holds $fields[fieldID] => data
// string $notify, text from tiny_mce editor option
// string $style, contains html header with style element and css

function modify_notify_message ($message, $fields, $notify, $style) {

     $message = str_ireplace('NAME', 'FULL NAME', $message);
     $message = str_ireplace('EMAIL', 'EMAIL ADDRESS', $message);

     return $message;
}
add_filter('kk_notify_message', 'modify_notify_message', 99, 4);

 

Use a priority of 11 or greater in this filter.  The content of the $message can vary depending on options you have selected.

This filter is similar to the one used in the Divi theme.  It is included here for use in modifying the wp_mail header array.

apply_filters( 'kk_contact_page_headers', $headers, $contact_name, $contact_email, $notification_msg ) );

This filter is discussed on the Errata page but is primarily used to customize the file type option list for the KK File Upload field type.

This action hook allows the captured field data to be used outside the processing of the form itself.

//passed to function -
//array $fields - contains $fields[field_id] => value (fields set to record to flamingo)
//array $args - contains $args[arg] => value which represent the non-field meta within flamingo
//string $form_id
function my_function($fields, $args, $form_id) {
//do something
}
add_action('kk_cust_form_cap', 'my_function, 11, 3 );

When using the Confirmation Email feature, it should be understood that there may be some situations that the designer will need to provide additional CSS considering that the email message will be transmitted as html to the email client.

Custom Form/CRM provides minimal styling, yet, includes all Custom CSS provided through the Theme Customizer and Divi’s Theme Options Custom CSS.  The kk_conf_style filter provides the means to augment or completely change what is delivered.  As an example, the following would represent one possibility of using the filter:

//passed to function -
//array $style - contains a string of html and style elements 
function kk_conf_style_filter($style) {
$style_tmp = $style;
if(strpos($style_tmp, '/* From Custom CSS */')) {
$style_tmp = substr_replace($style_tmp, file_get_contents(get_template_directory() . '/style-static.min.css'), strpos($style_tmp, '/* From Custom CSS */'), 0);
}
return $style_tmp;
}
add_filter('kk_conf_style', 'kk_conf_style_filter');

The above locates where the Custom CSS begins and inserts the Divi static CSS file. This is one example and is not necessarily recommended, but if a Page is selected to serve as the content for the email body, then Builder styling will need to be provided.

For Custom CSS entries, the class “confirmation” has been added to the element to aid in defining CSS specific to Confirmation emails.

If you need to modify the Success Message in any way, either by adding/removing verbiage, etc., this filter allows that and even allowing using the passed fields to compute the output before modifying the message.  This will enable using the form to produce content only and not emailing or saving the form input:

//passed to function -
//string $et_success_message - contains a string of html entered via the form settings
//array $notify_fields - array of fields flagged to be within the notify message

function get_the_quote($data) {
//do something to produce a quote
return $quote;
}
function kk_conf_success_message_filter($et_success_message, $notify_fields) {
$success_msg = $et_success_message;
if($notify_fields['hidden_field'] === 'provide_quote' {
$success_msg .=  get_the_quote($notify_fields);
}
return $success_msg;
}
add_filter('kk_success_message', 'kk_conf_success_message_filter', 10, 2 );

The above merely adds additional verbiage to any success message formulated in the module settings.  The filter could also replace the entire message, as well.