WordPress redirect the page if a user login is empty

I managed to make the redirect work with this function

add_action( 'wp_authenticate', '_catch_empty_user', 1, 2 );

function _catch_empty_user( $username, $pwd ) {
 if ( empty( $username ) ) {
   wp_safe_redirect( $redirect_to_whereever_you_want );
   exit();
 }
}

But when I go to the page www.mysite.com/wp-login.php, it still redirects no matter what.

Read More

Is it possible to make the wp-login.php page work as usual and only redirect when the actual login process is wrong or empty?

Thanks

Related posts