X

How to Hide Login Error Messages in WordPress

Snippets by IsItWP

Are you looking for a way to hide login error messages? For security reasons, you might want to hide the login messages that WordPress shows when someone is trying to login with the wrong information. The message “Invalid username” assists hackers in finding the right username and password, so with this snippet you can disable that message.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

 add_filter( 'login_errors', function( $errors ){ return ''; } ); 

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 6 Best WordPress Security Plugins Compared and how to create a popup form in WordPress.

Comments   Leave a Reply

  1. Ehm, PHP Deprecated: Function create_function() is deprecated. Learn to use debug and test before you add code like this.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!