Bypass a WordPress Password Protected Post or Page via a URL

You can use the same principle as the worked example, however replace $_GET with $_POST. So you’d have something like this towards the end:

// 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();