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?

link|improve this question
Show your code...then only we able to give answers – Ramkumar Jul 1 '11 at 10:49
feedback

1 Answer

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;
  if(isset($_COOKIE['wp-postpass_'.COOKIEHASH])
      && $_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...

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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