2. Add the code snippet below in your “functions.php” and edit accordingly.
// add comment notifier add_action('comment_post', 'notify_author_of_reply', 10, 2); function notify_author_of_reply($comment_id, $approved){ if(1 === $approved) { $comment = get_comment($comment_id); $comment_link = get_comment_link($comment_id); if($comment->comment_parent) { $parent_comment = get_comment($comment->comment_parent); wp_mail( $parent_comment->comment_author_email, 'Email Subject', 'Your message', 'Email Header' ); } } }
3. The add_action function will hook your notify_author_of_reply function whenever comment_post is triggered. Please change the name of notify_author_of_reply function to anything if you already has the function defined to do something else.
4. In notify_author_of_reply function, if the reply comment is approved, then only we send notification email via wp_mail. You can refer to wordpress documentation for more extensive reference.
5. And that’s all!
To see this function in action, you may drop a meaningful comment or feedback below and I will reply to yours. If you need help on this, do not hesitate to contact me.
Happy coding!