Site icon Hip-Hop Website Design and Development

When trying to login if already logged in, form just shakes – error message remains empty

I am already logged in (with role administrator). If I try to login again with wp-login.php the form just shakes – the error message above the form remains empty. Following a suggestion on this forum I added the following code to my theme’s function.php – it works:
/* Create error message for new login attempt if user is already logged in */

add_filter('login_errors','login_error_message');
function login_error_message($error){
    //create error message for already logged in
    $error = "You are already logged in";
    return $error;
}