Do you want to display a custom login error message on your WordPress site instead of the same old default message that is being displayed on every other WordPress site? While there is probably a plugin to accomplish this, we have created a quick code snippet that will do the job without having to install any 3rd party plugin.
Login to your WordPress site as an admin and go to Dashboard.
Now, navigate to Appearance -> Editor.
- Edit this page allows you to make changes to your theme files.
- Select the theme that you are using on your WordPress site.
- Select “functions.php” file.
In this example, we are using the “Twenty Sixteen” theme.
- Now, we are going to add a function that will pass the custom login error message.
- Add the following code (below) at the bottom of your functions.php file.
function add_custom_login_error_message(){
return ‘Wrong credentials – Sit back, relax and think about your login information for a minute and when you are sure, try again.’;
}
add_filter( ‘login_errors’, ‘add_custom_login_error_message’ );
In this code, we have created a function “function add_custom_login_error_message()”, and we are passing it to login error.
After saving your functions.php file, if you try to login to your WordPress site and enter incorrect login credentials, you should see this custom error message:
You can use the sample code snippet to insert your own copy for the login error and you did it without additional plugins.
Visit DiscountASP.NET to learn more about our WordPress hosting solutions
About Guest Blogger: Lavish Kumar
Based out of New York, USA, Lavish Kumar is a full stack web developer by profession and founder of Striving Programmers, a trusted community for developers that offers a wealth of articles and forums to assist individuals with improving their software development skills. He is passionate about writing tech articles and building great web applications. Lavish specializes in custom web applications, e-Commerce platforms, CMS implementation and CRM systems.