This answer assumes you are talking about the regular login page, /wp-login.php
, and that each user exists as a user in the WordPress database. After reading your question again I'm not so sure that is what you want to do.
This is a first attempt, but it is not complete because it asks for your password again on the protected post, and because it does not know when you want to visit /wp-admin/
or another restricted area.
add_filter( 'login_redirect', 'wpse6072_login_redirect', 10, 2 );
function wpse6072_login_redirect( $redirect_to, $requested_redirect )
{
// You somehow need to figure out how to make a difference between an admin login and a regular login
if ( /*! array_key_exists( 'redirect_to', $_REQUEST ) &&*/ array_key_exists( 'pwd', $_POST ) ) {
global $wpdb;
$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_password = %s", $_POST['pwd'] ) );
$post_permalink = get_permalink( $post_id );
if ( $post_permalink ) {
// TODO: Set the post password in a way that satisfied WordPress
$redirect_to = $post_permalink;
}
}
return $redirect_to;
}