Filters for customizing email notifications sent by Form Forge.
formforge_email_subject
Modify the admin notification email subject line before the email is sent.
Add priority prefix for urgent forms:add_filter( 'formforge_email_subject', function( $subject, $form, $submission_id ) {
if ( strpos( $form->title, 'Urgent' ) !== false ) {
$subject = '[URGENT] ' . $subject;
}
return $subject;
}, 10, 3 );add_filter( 'formforge_email_subject', function( $subject, $form, $submission_id ) {
global $wpdb;
$row = $wpdb->get_row( $wpdb->prepare(
"SELECT data FROM {$wpdb->prefix}formforge_submissions WHERE id = %d", $submission_id
) );
if ( $row ) {
$data = json_decode( $row->data, true );
$name = $data['field_1']['value'] ?? '';
if ( $name ) {
$subject .= ' from ' . $name;
}
}
return $subject;
}, 10, 3 );formforge_email_body
Modify the admin notification email body. The body is plain text by default.
Append a CRM link:add_filter( 'formforge_email_body', function( $body, $form, $data, $submission_id ) {
$body .= "nn---n";
$body .= "View in CRM: https://crm.example.com/leads/" . $submission_id;
return $body;
}, 10, 4 );add_filter( 'formforge_email_body', function( $body, $form, $data, $submission_id ) {
$html = '<div style="font-family:sans-serif;max-width:600px;">';
$html .= '<h2 style="color:#1e293b;">' . esc_html( $form->title ) . '</h2>';
$html .= '<table style="width:100%;border-collapse:collapse;">';
foreach ( $data as $field ) {
$html .= '<tr>';
$html .= '<td style="padding:8px;border-bottom:1px solid #e2e8f0;font-weight:600;">'
. esc_html( $field['label'] ) . '</td>';
$html .= '<td style="padding:8px;border-bottom:1px solid #e2e8f0;">'
. esc_html( $field['value'] ) . '</td>';
$html .= '</tr>';
}
$html .= '</table></div>';
return $html;
}, 10, 4 );
// Also set the content type to HTML
add_filter( 'wp_mail_content_type', function( $type ) {
return 'text/html';
} );—