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?