Hi
I have been searching high and low to find something that will allow me to stop unregistered browsers from reading comments on posts.
There are some sophisticated plugins that will probably work but they appear overkill and expensive !
So I found the following script which apparently only allow the post author and the commentator to see the comment - it seems perfect for me but I don't know where to put it !
<em>function restrict_comments( $comments , $post_id ){
global $post;
$user = wp_get_current_user();
if($post->post_author == $user->ID){
return $comments;
}
foreach($comments as $comment){
if( $comment->user_id == $user->ID || $post->post_author == $comment->user_id ){
if($post->post_author == $comment->user_id){
if($comment->comment_parent > 0){
$parent_comm = get_comment( $comment->comment_parent );
if( $parent_comm->user_id == $user->ID ){
$new_comments_array[] = $comment;
}
}else{
$new_comments_array[] = $comment;
}
}else{
$new_comments_array[] = $comment;
}
}
}
return $new_comments_array; }
add_filter( 'comments_array' , 'restrict_comments' , 10, 2 );
</em>
Maybe in Functions.php or comments.php ?
Any help will be gratefully received :)
the site is http://www.thewatchwithnoname.com
It is in experimental mode at the moment !