Frontend Comment Display
Frontend Comment Display
The Private Comments plugin modifies the standard WordPress comment loop to ensure privacy. Visibility is determined dynamically based on the current user's role and their relationship to the post or comment.
Visibility Rules
The following table defines which comments are visible to different user types on the frontend of your site:
| User Role | Own Comments | Others' Comments | | :--- | :--- | :--- | | Administrator | Visible | Visible | | Post Author | Visible | Visible | | Comment Author (Logged in) | Visible | Hidden | | Registered User (Non-author) | Hidden | Hidden | | Guest / Logged-out Visitor | Hidden | Hidden |
User Experience
For Unauthorized Users
Users who do not have permission to view comments (such as general visitors or other registered members) will see an empty comment section. The plugin also filters the comment count; for example, if a post has 10 private comments, a guest will see "0 Comments" to maintain total privacy.
For Comment Authors
When a user who has previously left a comment views the post, they will only see their own contributions. This allows them to track their discussion with the post author without exposing their message to the public.
For Administrators and Post Authors
Site administrators and the author of the specific post have full visibility. They will see the complete threaded discussion as it would normally appear in a standard WordPress installation.
Integration with Themes
The plugin hooks directly into the WordPress core comment queries (comments_clauses). This means it works out-of-the-box with any theme that uses standard WordPress functions to display comments, such as:
// Standard theme implementation (Works automatically)
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
Customization Note
Because the plugin filters the comments at the database query level, no additional configuration is required within your theme templates. If your theme uses a custom AJAX comment loader, the plugin will still restrict the data returned by those queries, ensuring no private data is leaked through the frontend API.