Suppressing login error reporting |


Please replace that code with the following:

function ps_disable_login_errors(){
  return ''; // or you can try return null
add_filter( 'login_errors', 'ps_disable_login_errors' );

I hope this will solve your issue.

Kind Regards


Great, thank you so much! I really appreciate it.

FWIW you could instead do

add_filter('login_errors', function() {
  return '';

as long as PHP v5.3+ is used. The ability to create anonymous functions like this is in part the reason create_function() was deprecated. Except for very simple things like this, I personally think using named functions like Prashant suggests is better for anything more complicated because it makes your code clearer and more readable.

Because the returned value is used in an echo statement, returning an empty string is more appropriate than null.

@bcworkz: I did decide to create a named function as @prashantvatsh suggested, and decided to return an error string that’s not empty, but is less specific than the default values. (I tried the empty string approach, but concluded that it would be better even for me — the only one who normally needs to log in — to return some kind of visible error so that it doesn’t seem like the login window is malfunctioning if I enter something incorrectly.)

Thanks again for your input!

Source link