[wp-hackers] Password protected post - how to require password everytime

Andrew Nacin wp at andrewnacin.com
Fri Nov 12 12:36:23 UTC 2010


On Fri, Nov 12, 2010 at 7:05 AM, Pavel Hejn <pavelevap at post.cz> wrote:

> Hello,
>
> when using password protected post and user inserts right password, then it
> is probably saved in cookies, because when displaying this post again, no
> password is required. But it is problem for some users (for public
> computers, etc.).
> I did not find any hook to change this behaviour and require password
> everytime.
> Is there any chance to do it as a small plugin?
>

This works for me:

add_action( 'wp', 'post_password_immediately_expires' );
function post_password_immediately_expires() {
    if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) )
        setcookie('wp-postpass_' . COOKIEHASH, '', time() - 31536000,
COOKIEPATH);
}


More information about the wp-hackers mailing list