• Can somebody give me some reference on:

    How to check if the post/page is password protected and whether the viewer has access (entered correct password).

    Ive been googling for hours now. 🙁 . I was hoping theres some functions like.

    is_password_protected();
    and
    is_password_ok()
    anythin like that. 🙂

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • How to check if the post/page is password protected

    2.5.1 doesnt have post_password_required() function so I think you can use ↓ (inside WP posts loop)

    if(!empty($post->post_password) and $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password)){
     // this post is password protected
    }

    … whether the viewer has access (entered correct password).

    if (isset($_COOKIE['wp-postpass_' . COOKIEHASH])
     and $_COOKIE['wp-postpass_' . COOKIEHASH] == $post->post_password){
      // correct pass
    }

    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...
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Template to be protection aware.’ is closed to new replies.