wp list all users who haven’t commented on a post

I’m trying find a way in my single.php to list all users (display name) that haven’t commented on the current post.

I have this snippet that lists all the users who have commented…

/**
* Display a list of comment authors’ names.
*
* @param int $id Optional. Post ID.
* @param string $sep Optional. List separator.
* @return null
*/
function the_comment_authors_list( $id = 0, $sep = ‘, ‘ ) {
echo get_comment_authors_list( $id, $sep );
}

/*
* Available parameters for the Shortcode:
* int post_id Optional. Post ID.
* string list_sep Optional. List separator.
*
* Usage examples:
* [comment_authors_list /]
* [comment_authors_list post_id=”1″ list_sep=” · ” /]
*/
add_shortcode( ‘comment_authors_list’, ‘comment_authors_list_shortcode’ );

/**
* Shortcode callback function.
*
* @see get_comment_authors_list()
* @return string|null Names list.
*/
function comment_authors_list_shortcode( $atts = array() ) {
$atts = shortcode_atts( array(
‘post_id’ => 0,
‘list_sep’ => ”,
), $atts );

return get_comment_authors_list( $atts[‘post_id’], $atts[‘list_sep’] );
}

Read more here:: wp list all users who haven’t commented on a post

Leave a Reply

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