The function you are using– post_password_required
— is true for password protected pages, not for private pages. I am honestly not sure which you mean, but if you do mean “private” as in most of your description then…
I am not aware of an is_private
function but you can check the post object itself. There is a catch though. “Private” posts are rabidly protected. A user without permissions to see the post will get a 404. I think the following will work, but due to the nature of “private” posts this may still be buggy. It has not been rigidly tested.
function redirect_to_login() {
global $wp_query,$wpdb;
if (is_404()) {
$private = $wpdb->get_row($wp_query->request);
if( 'private' == $private->post_status ) {
wp_safe_redirect(home_url(get_permalink(188)));
die;
}
}
}
add_action('template_redirect', 'redirect_to_login');