Password Protect Page Template (8 posts)

  1. Derek Perkins
    Posted 6 years ago #

    I have a page that I want to password protect, but it is based on a page template that pulls in all the data to be displayed outside of WordPress, not from the post content. When I password protect the post, it does nothing to protect the content. How can I tie into the WordPress system to protect that content?

  2. gregorylepacha
    Posted 6 years ago #


  3. ericbarbosajr
    Posted 6 years ago #


    i was hoping that get_the_content() would return false if the page is password protected. This way we can determine when to show a password prompt.

  4. Derek Perkins
    Posted 6 years ago #

    I'd really like to be able to tie into the password system.

  5. darknailblue
    Posted 6 years ago #

    i hear ya... I'm having the same problem... I started working on a plugin that will enable a conditional tag so that this is possible

    I know that it is possible but haven't been getting anywhere with it...

  6. darknailblue
    Posted 6 years ago #

    Turns out I don't need to write a plugin that does this... The conditional function that you want to use is...


    Basically, this returns a true value if you are entered the password on the page or if the cookie is set.

    It took some digging but, this helped me out a great deal...

  7. cebradesign
    Posted 6 years ago #

    Could it be something like...

    if(!empty($post->post_password) and $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password)){
     // here what to tell the visitor: it's a protected page blah
    the_content(); // here we ask WP to ask for a password, content should be blank
    if (isset($_COOKIE['wp-postpass_' . COOKIEHASH])
     and $_COOKIE['wp-postpass_' . COOKIEHASH] == $post->post_password){
      // here it's the protected stuff...

    (taken from wp support forum)

    Hope it's clear or helpful...

  8. Andy Potanin
    Posted 5 years ago #

    In case you are looking to modify the generic "This post is password protected. To view.." form, you can add a filter into the functions.php file, like so:

    add_filter('the_password_form', 'custom_the_password_form');
    function custom_the_password_form() {
      return $output;

    You can view the original code in post-template.php on lines 1132 - 1141.

Topic Closed

This topic has been closed to new replies.

About this Topic