Views: 2324 July 26, 2021
WordPress Security is essential for login fishing – Hide Login Errors
Error login messages may expose and give hackers an idea if they’ve gotten username correct/incorrect, vice versa. It is wise to hide it from unauthorized login.
To hide login error messages, you can simply put the following code in functions.php
add_filter( 'login_errors', '__return_false' );
WordPress Logo and Security error notifications
To further change the WordPress logo and security error messages you can use the below code. This code you can place in functions.php located in child-theme.
/** start change default error messages and login wp logo **/ function my_custom_error_messages() { global $errors; $err_codes = $errors->get_error_codes(); // Invalid username. if ( in_array( 'invalid_username', $err_codes ) ) { $error = '<strong>ERROR</strong>: custom error message.'; } // Incorrect password. if ( in_array( 'incorrect_password', $err_codes ) ) { $error = '<strong>ERROR</strong>: custom error message.'; } return $error; } add_filter( 'login_errors', 'my_custom_error_messages'); function my_login_logo() { ?> <style type="text/css"> #login h1 a, .login h1 a { background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/image-name.jpg); width: 320px; background-size: 320px; background-repeat: no-repeat; } </style> <?php } add_action( 'login_enqueue_scripts', 'my_login_logo' ); function my_login_logo_url() { return home_url(); } add_filter( 'login_headerurl', 'my_login_logo_url' ); function my_login_logo_url_title() { return 'ImpulseByte - ecommerce expert company'; } add_filter( 'login_headertitle', 'my_login_logo_url_title' ); /** end change default error messages and login wp logo **/