• Resolved Pete

    (@perthmetro)


    I have a strange request…

    I want to keep a page’s comment section visible and open to the public to post comments, But I don’t want anyone except the admins to be able to view the submitted comments. I don’t even want the commenter to see their submitted posts.

    Would anyone have a snippet of code for this?

    Thanks,
    Pete

Viewing 6 replies - 1 through 6 (of 6 total)
  • You could turn on moderation of comments but don’t approve any of the comments. At Settings > Discussion set “Before a comment appears” to
    “Before a comment appears Comment must be manually approved”

    Did I understand your request correctly?

    Thread Starter Pete

    (@perthmetro)

    Yes I could, thanks, but I’d like to read the comments on the front end.

    What about this?

    <?php if (current_user_can( 'manage_options' )): ?>
        ...
    
    <?php endif; ?>

    Then you can display the comments inside that block, stopping any user that doesn’t have manage_options permissions from seeing it.

    vato

    (@vatanbytyqi)

    I think you have to create a custom template for comments and in that template you can do this check before printing the comments:

    if ( current_user_can( 'manage_options' ) ) {
       wp_list_comments();
    }

    This is the filter for including a custom template for comments:
    add_filter( “comments_template”, “my_function_for_inclusion”, 1 );

    If you find a simpler solution please let me know

    Thread Starter Pete

    (@perthmetro)

    Will this still allow the commenter to see the form?

    Thread Starter Pete

    (@perthmetro)

    Thanks catacaustic and vatanbytyqi, works a treat ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Hide submitted comments from everyone (including commenter) except admin’ is closed to new replies.