Custom Failed Login Message

24 Jul

Custom Failed Login Message

Context:You want to display custom message when user login fails.

Solution:The snippet given below is good to add to every theme you create as it can help massively with your websites security. What is does is overrides what WordPress outputs when the user log’s in incorrectly. As some of you may know when you get the password wrong for an account that exists WordPress will actually output a message saying the password for that account is wrong. Therefore telling the hacker that there is actually an account with that username to hack.

// Change the failed login message for extra WordPress Secruty
function failed_login() {
    return 'Incorrect login information.';
}
add_filter('login_errors', 'failed_login');

Bydr.code.skm

I am backend developer with passion in Web Application development using latest technologies like Laravel, PHP7, React, ECMAScript 6 and WordPress. I prefer spending time analyzing big data with Apache Spark. Apart from that, I do photography.