The comment_moderation_text WordPress PHP filter allows you to modify the text of the comment moderation email.
Usage
add_filter('comment_moderation_text', 'your_custom_function', 10, 2); function your_custom_function($notify_message, $comment_id) { // your custom code here return $notify_message; }
Parameters
$notify_message
(string) – Text of the comment moderation email.$comment_id
(int) – Comment ID.
More information
See WordPress Developer Resources: comment_moderation_text
Examples
Add a custom note to the moderation email
Add a custom note to the comment moderation email text.
add_filter('comment_moderation_text', 'add_custom_note', 10, 2); function add_custom_note($notify_message, $comment_id) { $custom_note = "Please moderate the comment carefully."; $notify_message .= "\n\n" . $custom_note; return $notify_message; }
Change the email greeting
Change the default greeting in the comment moderation email.
add_filter('comment_moderation_text', 'change_email_greeting', 10, 2); function change_email_greeting($notify_message, $comment_id) { $new_greeting = "Hello Moderator,"; $notify_message = preg_replace('/^A new comment/', $new_greeting, $notify_message); return $notify_message; }
Add the comment author’s email to the moderation email
Include the comment author’s email address in the comment moderation email.
add_filter('comment_moderation_text', 'add_author_email', 10, 2); function add_author_email($notify_message, $comment_id) { $comment = get_comment($comment_id); $author_email = $comment->comment_author_email; $notify_message .= "\n\nAuthor Email: " . $author_email; return $notify_message; }
Remove the comment content from the moderation email
Remove the comment content from the comment moderation email.
add_filter('comment_moderation_text', 'remove_comment_content', 10, 2); function remove_comment_content($notify_message, $comment_id) { $notify_message = preg_replace('/\n\nComment:.*$/s', '', $notify_message); return $notify_message; }
Add a custom footer to the moderation email
Add a custom footer to the comment moderation email.
add_filter('comment_moderation_text', 'add_custom_footer', 10, 2); function add_custom_footer($notify_message, $comment_id) { $footer = "Thank you for your hard work!"; $notify_message .= "\n\n" . $footer; return $notify_message; }