您可以使用与工作示例相同的原理,但是$_GET
具有$_POST
. 所以在最后你会看到这样的情况:
// Your custom check for the \'$_POST\' content
// …also check if there in fact is a password
// …and if the user is a repeated visitor, do not set the Cookie again
if (
isset( $_POST[\'circumvent\'] )
and \'disable-pass\' === $_POST[\'circumvent\']
and isset( $post->post_password )
and ! isset( \'wp-postpass_\'.COOKIEHASH )
) {
// Finally we use the plain text password to set the Cookie
// as if the user would have entered it into the password form
setcookie(
\'wp-postpass_\'.COOKIEHASH,
$hasher->HashPassword( wp_unslash( esc_attr( $post->post_password ) ) ),
$expire,
COOKIEPATH
);
}
// Now display the content:
the_content();