Skip to main content

Mailer

Pre-post parameters filter

Allows modifying form field data before it's sent to mailer system. Useful if you want to make values derived from the sent data, or add new fields.

add_filter('es_forms_integrations_mailer_pre_post_params', 'getIntegrationPrePostParams', 10, 2);

/**
* Modifies form field data before it's sent to mailer system.
*
* @param array<string, mixed> $params Array of params.
* @param string $formId Form ID.
*
* @return array<string, mixed>
*/
function getIntegrationPrePostParams(array $params, string $formId): array
{
$formSubmissionPageLt = $params['form_submission_page_lt']['value'] ?? '';

if ($formSubmissionPageLt) {
$params['ib-submission-source'] = [
'name' => 'ib-submission-source',
'value' => $formSubmissionPageLt,
'type' => 'text',
'internalType' => '',
];
}

return $params;
}

Before success response filter

Allows modifying the response data before it is sent back to the client after a successful form submission. Runs after all internal processing (entries, variations, redirects) is complete.

add_filter('es_forms_integrations_mailer_before_success_response', 'getIntegrationBeforeSuccessResponse', 10, 3);

/**
* Modify the response before it is sent to the client.
*
* @param array<string, mixed> $response Response data with 'private', 'public', and 'additional' keys.
* @param array<string, mixed> $formDetails Full form submission details.
* @param string $formId Form ID.
*
* @return array<string, mixed>
*/
function getIntegrationBeforeSuccessResponse(array $response, array $formDetails, string $formId): array
{
$response['additional']['myCustomKey'] = 'myCustomValue';

return $response;
}

After custom result output process filter

Allows modifying the processed custom result output data after it has been prepared. Useful when using the custom result output feature to adjust the final output structure.

add_filter('es_forms_integrations_mailer_after_custom_result_output_process', 'getIntegrationAfterCustomResultOutputProcess', 10, 3);

/**
* Modify the custom result output data after processing.
*
* @param array<string, mixed> $output Processed output with 't' (title), 'st' (subtitle), and 'd' (data) keys.
* @param array<string, mixed> $formDetails Full form submission details.
* @param string $formId Form ID.
*
* @return array<string, mixed>
*/
function getIntegrationAfterCustomResultOutputProcess(array $output, array $formDetails, string $formId): array
{
$output['t'] = __('Custom title', 'text-domain');

return $output;
}

Body template

Allows modifying the full HTML email body before it is sent via wp_mail. Useful for wrapping content in a custom email template or adding a header/footer.

\add_filter('es_forms_integrations_mailer_body_template', [$this, 'getMailerBodyTemplate'], 10, 4);

/**
* Modify the email body template before sending.
*
* @param string $body Full HTML email body (wrapped in <html><body> tags).
* @param string $formId Form post ID.
* @param string $template Email template content.
* @param array<string, mixed> $params Prepared field name/value pairs.
*
* @return string
*/
public function getMailerBodyTemplate(string $body, string $formId, string $template, array $params): string
{
return '<!DOCTYPE html><html><body style="font-family: sans-serif;">' . $template . '</body></html>';
}