• Hi all,
    I’m trying to build some community features into my site, and one of the things I’d like to do on the profile page is show all the last 15 comments by that user, and what thread they were posted in.

    I can’t find codex to help me out with this anywhere. If anyone can help me out, I’d be very grateful.

    Thanks-

Viewing 3 replies - 16 through 18 (of 18 total)
  • thanx all :D, … just wanted to share the function “get_comment_link”, to get the right comment link, in case u have multi paged comments:

    echo "<li><a href='". get_comment_link($comment->comment_post_ID)."'>Comment on ". $comment->post_title ."</a></li>";

    sorry but cant edit my post above….

    echo "<li><a href='". get_comment_link($comment->comment_ID)."'>Comment on ". $comment->post_title ."</a></li>";

    its $comment->comment_ID and NOT $comment->comment_post_ID

    how would it be possible to make this code in the sidebar as a widget? At the moment no results are shown.

    It works great within the authors page but I would like to be able to alter this code so that it shows the current users (who is logged in) recent comments.

    I’ve played about with the code and I have:

    <?php
    if ( is_user_logged_in() ) {
      $user_id = get_current_user_id();
    
    endif;
    $querystr = "
        SELECT comment_ID, comment_post_ID, post_title, comment_content
        FROM $wpdb->comments, $wpdb->posts
        WHERE user_id = $user_id->ID
        AND comment_post_id = ID
        AND comment_approved = 1
        ORDER BY comment_ID DESC
     ";
    ?>
    
    <h2>Recent Comments </h2>
    <ul>
    <?php foreach ($comments_array as $comment):
    	setup_postdata($comment);
    	echo "<li><a href='". get_bloginfo('url') ."/?p=".$comment->comment_post_ID."'>Comment on ". $comment->post_title. "</a><br />". $comment->comment_content . "</li>";
    endforeach; ?>
    </ul>

    But this doesn’t work.

    Any ideas?

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Show only comments by specific registered user’ is closed to new replies.