The comment_moderation_headers WordPress PHP filter allows you to modify the headers for the comment moderation email.
Usage
add_filter('comment_moderation_headers', 'my_custom_comment_moderation_headers', 10, 2); function my_custom_comment_moderation_headers($message_headers, $comment_id) { // your custom code here return $message_headers; }
Parameters
$message_headers
: string – Headers for the comment moderation email.$comment_id
: int – Comment ID.
More information
See WordPress Developer Resources: comment_moderation_headers
Examples
Add custom CC and BCC
Add a custom CC and BCC email address to the comment moderation email headers.
function add_cc_bcc_to_comment_moderation_email($headers, $comment_id) { $headers .= "CC: [email protected]\r\n"; $headers .= "BCC: [email protected]\r\n"; return $headers; } add_filter('comment_moderation_headers', 'add_cc_bcc_to_comment_moderation_email', 10, 2);
Change Reply-To address
Change the Reply-To address in the comment moderation email headers.
function change_reply_to_address($headers, $comment_id) { $headers .= "Reply-To: [email protected]\r\n"; return $headers; } add_filter('comment_moderation_headers', 'change_reply_to_address', 10, 2);
Add X-Priority header
Add an X-Priority header to set email priority for the comment moderation email.
function add_x_priority_header($headers, $comment_id) { $headers .= "X-Priority: 1\r\n"; return $headers; } add_filter('comment_moderation_headers', 'add_x_priority_header', 10, 2);
Change content type
Change the content type of the comment moderation email to HTML.
function change_content_type_to_html($headers, $comment_id) { $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; return $headers; } add_filter('comment_moderation_headers', 'change_content_type_to_html', 10, 2);
Add custom header
Add a custom header to the comment moderation email.
function add_custom_header($headers, $comment_id) { $headers .= "X-Custom-Header: custom-value\r\n"; return $headers; } add_filter('comment_moderation_headers', 'add_custom_header', 10, 2);