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:
<?php if ( have_comments() ) : ?>
<ol class="commentlist">
<?php wp_list_comments(); ?>
</ol>
<?php if ( ! comments_open() ) : ?>
<p class="no-comments">Comments are closed</p>
<?php endif; ?>
<?php endif; ?>
What do I need to place around this code to filter the comments and show them only to their owners? Thanks.
You need to edit the comments template and use a combination of this
which returns the user id of whoever commented, and compare it to the current user with
Both return 0 if the commenter wasn't registered or if the current user isn't logged in, respectively.