I am using the code below to count the number of comments by a certain user:
global $wpdb;
$count = $wpdb->get_var(
'SELECT COUNT( comment_id ) FROM '. $wpdb->comments .'
WHERE user_id = '.$user->ID.'
AND comment_approved = "1"
AND comment_type NOT IN ("pingback", "trackback" )'
);
I am in addition, using a comment meta field ('consider') which takes 0 or 1 as values. To get its value I use:
get_comment_meta($comment_id, 'consider',true);
How can I merge these two operations so that I get the number of comments submitted by the user and which have the meta value 'consider'
equal to 1
? I am not an SQL user and it seems that I need to use inside my SQL query the table wp_commentmeta
?
Your help is always appreciated.