WordPress.org

Support

Support » How-To and Troubleshooting » show all comments of a user… how?

show all comments of a user… how?

Viewing 11 replies - 1 through 11 (of 11 total)
  • up

    Please don’t bump.

    Comments are stored per-page/post, rather than per user, which means this would be a fairly intensive SQL call to pull up all the comments.

    WP-Stats – http://wordpress.org/extend/plugins/wp-stats/ – can do this, but IIRC it only shows the people with 5+ comments.

    Michael

    @alchymyth

    Forum Moderator

    get_comments()
    http://codex.wordpress.org/Function_Reference/get_comments

    for instance something like this, in author page:

    <?php
    $author_email = get_the_author_meta( 'user_email' ); 
    
    $args = array(
    	'author_email' => $author_email
    );
    $comments = get_comments($args);
    foreach($comments as $comment) :
    	echo('<br />' . $comment->comment_date . '<br />' . $comment->comment_content);
    endforeach;
    ?>

    Does that actually work without a post_id though? Interesting.

    Michael

    @alchymyth

    Forum Moderator

    the docu is not very clear – i wonder myself which parameter would take precedence?

    the snippet did return the comments made by the author (local install, not many comments or authors in the system) – obvious only as long he used his email for commenting.

    also interestingly, in contrast to the codex, the argument list of get_comments() in /wp-includes/comment.php does not include the ‘author_email’

    173   * The list of comment arguments are 'status', 'orderby', 'comment_date_gmt',
     174   * 'order', 'number', 'offset', and 'post_id'.

    Clearly something to experiment with 🙂

    I would guess that user_id would be a preferable search parameter than the author email, personally.

    Ευχαριστώ πάρα πολύ!!!

    Thank you very much…

    I will take a look at thois right ahead and i will respond back

    Michael

    @alchymyth

    Forum Moderator

    @ipstenu

    I would guess that user_id would be a preferable search parameter than the author email, personally.

    just checked – user_id results in the same comments returned as the corresponding email address.

    hours of fun and joy ahead 😉

    Yeah, but if someone changes their email, you won’t have ’em all. Where as user_id remains constant.

    there is no author.php in my theme…
    where should i add this code?

    alchymyth solution is pretty effective!

    I’m really new in WordPress theme development, and I’m wanting to change the author_email to user_id. I’ve changed all author_email and user_email to user_id, but what it does is showing all comments from all users.

    I’ve tried reading the codex but didn’t find something helpful. Any help here?

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘show all comments of a user… how?’ is closed to new replies.
Skip to toolbar