Redirect user on failed login in wordpress

Often we come across the situations when we need to redirect a user to a particular page if the login attempt was failed.

This can be done by using following simple snippet

// use the hook 'wp_login_failed'

add_action( 'wp_login_failed', 'at_login_failed' );
function at_login_failed()
wp_redirect( $url ); // url to redirect to