Greetings. I'm trying to set up a password-protected page using in Wordpress,
using a custom template.
I'd like to prompt for the password and then, if it's correct, enter a
"query_posts" loop to display all the posts matching a given category.
I found the following on the web:
if(!empty($post->post_password) &&
$_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {
the_content(); // this will be used to display password form
}
if (isset($_COOKIE['wp-postpass_' . COOKIEHASH]) &&
$_COOKIE['wp-postpass_' . COOKIEHASH] == $post->post_password) {
<enter the query-posts loop>
}
I can't get this to work. If I echo the relevant stuff, I get:
echo $post->post_password;
<the plain-text version of the password I associated with the page>
echo md5($post->post_password);
904f6cabe...
echo crypt($post->post_password);
$6$FEb8N2Q0$...
echo $_COOKIE['wp-postpass_' . COOKIEHASH];
$P$BQOWJ...
The test for equality in the second "if" statement above always fails, for the
plain-text, the md5, and the crypt versions of the password.
I'm clearly doing something wrong. Can somebody point me in the right
direction? Thanks.
--Mike