WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

From the users section, I can see a link to their posts, but not their comments. When I go to comments, there doesn't seem to be a straightforward way to filter only comments by a specific user. How to do it? (I'm sure such basic feature must be somewhere, I just can't find it.)

share|improve this question

Afaik, there's no straight forward way for this.

You'd have to extend the WP_List_Table and add an extra column. This would be an example function:

function wpse_get_comments_by_user( $user_ID )
    global $wpdb;

    $rows = $wpdb->query( $wpdb->prepare(
            SELECT * 
            FROM %s
            WHERE user_id = %d
        ,(int) $user_ID
    ) );

   return $rows;

The above ↑ function gives you back all DB rows for comments by the user you specified by her/his ID.

You then can go and list for e.g. all posts in a foreach loop:

foreach ( wpse_get_comments_by_user( $user->ID ) as $comment )
    $post_link = get_permalink( $comment->comment_post_ID );

    echo "<a href='{$post_link}'>";
        // apply the excerpt filters in case the comment content is too long
        echo apply_filters( 'the_excerpt', $comment->comment_content );
        // Add the date
        echo $comment->comment_date;
    echo '</a>';

The actual problem is that there's no admin screen where you can list comments by user. So I'd say it'd be easier to do this with a link and a page-template where you hide the contents behind current_user_can( 'manage_options' );.

share|improve this answer
Great, thanks. I think the Admin / Users page would be a good place for this. – Borek Feb 29 '12 at 17:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.