How to password protect a page template?
-
I am trying to password protect the template output on a page, but it’s not working. The template output just shows up under the prompt to ask for the password.
I’ve found this code but it doesn’t work:
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... }
When I put the stuff I’m trying to protect in the section there, it never shows up, even after entering the password.
I’m using a custom template within one of the themes from Elegant Themes.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to password protect a page template?’ is closed to new replies.