Comments to only be seen by their author

Question

I am currently attempting to make comments that only the author when logged in can see those posts. Two different logins to the website cannot see each other’s posts.

I have found some stuff online like a function to attempt this. However, every time I use this it breaks the site. I have done some research on applying filters and using the WP hook to do so. I unfortunately haven’t been able to accomplish this.

Can this be done just by altering the select where clause? To filter database off of user id and then capturing logged in user id through php?

//After the comments are fetched, you can modify the comments array
add_filter('the_comments', 'wpse56652_filt_comm');

function wpse56652_filt_comm($param) {
global $current_user;
get_currentuserinfo();

//current users id = $current_user->ID;

//Current users posts, check get_posts params to change as per your need
$user_posts = get_posts(array('author' => $current_user->ID, 'posts_per_page' => -1));

echo '<pre>';
print_r($param);
echo '</pre>';

return $param;
}

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/comments-to-only-be-seen-by-their-author/">

Comments to only be seen by their author</a>
0
, , , andy 3 months 0 Answers 40 views 0

Leave an answer