Support » Fixing WordPress » Comments box appearing on password page

  • Resolved sonesh

    (@sonesh)


    I’m new to wordpress, but have solved many of my problems by reading this forum, except one.

    I’ve password protected a lot of my pages, which is working fine, but I’ve just noticed pages which can be commented on, show the “Leave a Reply” form even if you’ve not entered the password.

    http://wedding.sonesh.co.uk/your-contributions/sign-our-guestbook/

    Pressing submit takes you to a blank page and doesn’t post the comment, but works fine if you’ve entered the password, but I can see this being a problem if people are too lazy to enter the password.

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    Look for this in your theme’s page.php:

    <?php comments_template(); ?>

    And change it to this so the comment form only displays on pages that are not password protected and on pages where the password has been provided [untested]:

    <?php
    if(!post_password_required( $post )) {
    comments_template();
    }
    ?>

    http://codex.wordpress.org/Function_Reference/post_password_required

    It actually seems to have fixed itself. Now that people have put comments in, the form has been replaced with:

    This post is password protected. Enter the password to view comments.”

    Thanks anyway

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Comments box appearing on password page’ is closed to new replies.