This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
This hook can be used to edit or replace the message body of an email sent by a form.
Usage
add_filter('frm_email_message', 'add_email_header', 10, 2); function add_email_header($message, $atts)
Parameters
- $message (string)
- $atts (array)
Examples
Add Header Image to Emails
You can use the example below to add a static image header to all emails sent from your forms. Replace the URL below with an image URL of your choice.
add_filter('frm_email_message', 'add_email_header', 10, 2);
function add_email_header($message, $atts) {
//edit the email header image source to include an image URL of your choice
$email_header = '<img src="http://www.yoursite.com/images/email-header.jpg" alt="Header" /><br />';
$message = $email_header . $message;
return $message;
}
Add a preheader
For a clear and concise summary displayed next to your subject line, use this code snippet to add a preheader to your emails.
add_filter('frm_email_message', 'add_email_header', 10, 2);
function add_email_header($message, $atts) {
if (isset($atts['form']) && $atts['form']->id == 1) { //replace 1 with the ID of the form
$email_header = 'This is the preheader text';
$message = $email_header . $message;
}
return $message;
}