Hook/Filter after comments post – get notification after post comment via email

please click here for more wordpress cource

Hook/Filter after comments post and send email Or Get notified via email when a user posts a comment on your site’s blog. If you want to send email when user post a comment on single post page then this tutorial is very help full for you.

function wpaccuracy_notify_my_mail( $comment_id, $comment_approved ) {
    if ( ! $comment_approved ) {
        $comment = get_comment( $comment_id );
        $mail = 'admin@wpaccuracy.org';
        $subject = sprintf( 'New Comment by: %s', $comment->comment_author );
        $message = $comment->comment_content;
 
        wp_mail( $mail, $subject, $message );
    }
}
add_action( 'comment_post', 'wpaccuracy_notify_my_mail', 10, 2 );

You may also like...

Popular Posts

Leave a Reply

Your email address will not be published. Required fields are marked *