Ok guys, I'm building a page, where a certain sub-page is password protected. Easy in wordpress. But there is a UX problem: when a user enters a wrong password, theres no error message or something to indicate, that the password is not correct.

Is it posible to manually code it somehow to the template file?

  • Show your code...then only we able to give answers
    – Ramkumar M
    Commented Jul 1, 2011 at 10:49

1 Answer 1


not really, but can try something like:

add_action('wp', 'check_post_pass');

function check_post_pass(){

  if(!is_single() || !post_password_required()) return;

  global $post;
      && $_COOKIE['wp-postpass_'.COOKIEHASH] !== $post->post_password){

    define('INVALID_POST_PASS', true);

    // tell the browser to remove the cookie so the message doesn't show up every time
    setcookie('wp-postpass_'.COOKIEHASH, NULL, -1, COOKIEPATH);


in your template:

if(defined('INVALID_POST_PASS')) _e('The password you entered is funky');

But a much better idea would be to create your own the_content()-like function and password form + check function, without cookies...

  • Just noting that as of WP v3.4 passwords are hashed in cookies Commented Oct 3, 2016 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.