Display the number of user comments

Got some idea from here.
User’s comments have posted

<?php
function commentCount() {
    global $wpdb;
    $count = $wpdb->get_var('SELECT COUNT(comment_ID) FROM ' . $wpdb-comments. ' WHERE comment_author_email = "' . get_comment_author_email() . '"');
    echo $count . ' comments';
}

commentCount();
?>

I don’t have any idea for comments that user got from their posts. Might be use custom $wpdb query too, where post_id is array of their post id.

Leave a Comment