I want to translate the above message which appears on invalid username.
I know the answer is very similar to the one proposed here by I cannot find the exact handler.
Thank you.
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI want to translate the above message which appears on invalid username.
I know the answer is very similar to the one proposed here by I cannot find the exact handler.
Thank you.
In the en_GB version of the .mo translation file, this string is available:
<strong>ERROR</strong>: Invalid username. <a href=\"%s\" title=\"Password Lost and Found\">Lost your password</a>?
and the reference is from wp-includes/user.php on line 93. I found this using Poedit and searching using Ctrl + F.
From line 93 we get the following code:
return new WP_Error( 'invalid_username', sprintf( __( '<strong>ERROR</strong>: Invalid username. <a href="%s" title="Password Lost and Found">Lost your password</a>?' ), wp_lostpassword_url() ) );
Which means you should write a function for your functions.php hooking into invalid_username
like so:
add_filter( 'wp_login_errors', 'override_incorrect_username_message', 10, 2 );
function override_incorrect_username_message( $errors, $redirect_to ) {
if( isset( $errors->errors['invalid_username'] ) ) {
$errors->errors['invalid_username'][0] = 'Your new translated message';
}
return $errors;
}
You can hunt around in wp-includes.php for other similar error messages which you can fix in a similar way.