I'm building a site for a research and my participants will be all logged in to use the site. I would like to make these participants able to see only their own comments, so other users' comments will be hidden.
I'm using the comments.php file with, among other things, this simple code and a callback to format the comments output:
<?php if ( have_comments() ) : ?>
<ol class="commentlist">
<?php wp_list_comments( 'type=comment&callback=custom_comentarios' ); ?>
</ol>
<?php if ( ! comments_open() ) : ?>
<p class="no-comments">Comments are closed</p>
<?php endif; ?>
<?php endif; ?>
And this simple code on functions.php to format the comments output:
<?php
/* Custom callback function for displaying comments, see comments.php */
function custom_comentarios($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div id="comment-<?php comment_ID(); ?>">
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your comment is awaiting moderation.') ?></em>
<br />
<?php endif; ?>
<?php comment_text() ?>
</div>
<?php
}
?>
What do I need to place around this code to filter the comments and show them only to their owners? I have to mention that I'm not a programmer and I don't know php syntax :-/ I know that it will be something like: get the current user, check if there's a comment from the current user on the current post, if true then show comment. But how to write this in php?