Getting comments of an specefic user

You could try this way: <?php $my_user = get_current_user_id(); $args = array( ‘post_type’ => ‘custom-post-type’, ‘user_id’ => $my_user, ); $comments = get_comments($args); foreach($comments as $comment) : echo($comment->comment_author . ‘<br />’ . $comment->comment_content); endforeach; ?> Provided that your user has comments!!

Fetching Initials of the Commentator in the WordPress Website

Here is function that return you the comment author initials by the comment id function get_comment_author_initials($comment_id) { $author = get_comment_author($comment_id); $words = explode(” “, $author); $initials = null; foreach ($words as $w) { $split = mb_str_split($w); // to cover unicode char $initials .= $split[0]; } return $initials; } function mb_str_split( $string ) { return preg_split(‘/(?<!^)(?!$)/u’, … Read more

Sending comment notifications to different recipients depending on taxonomy terms

Finally I found the right code, if it can be usefull to someone: function sp_comment_moderation_recipients( $emails, $comment_id ) { $comment = get_comment( $comment_id ); $post = get_post( $comment->comment_post_ID ); if ( has_term(‘myterm’,’mytaxonomy’, $post->ID) ) { return array( ‘[email protected]’ ); } return $emails; } add_filter( ‘comment_moderation_recipients’, ‘sp_comment_moderation_recipients’, 10, 2 ); add_filter( ‘comment_notification_recipients’, ‘sp_comment_moderation_recipients’, 10, 2 );