The login_messages
filter allows you to modify various messages shown on the login screen.
It is evaluated in login_header()
in the wp-login.php file.
Messages include:
- ‘Session expired. Please log in again. You will not move away from this page.’
- ‘You are now logged out.’
- ‘User registration is currently not allowed.’
- ‘Check your e-mail for the confirmation link.’
- ‘Check your e-mail for your new password.’
- ‘Registration complete. Please check your e-email.’
- You have successfully updated WordPress! Please log back in to experience the awesomeness.
login_messages
accepts a single argument taking the form of a string containing the message for the context.
It’s important to remember that login_messages is evaluated as a string, not an array of messages like elsewhere in Core. The string delivered is determined based on the provided context in the query string. If you want to modify the message as stored in the WP_Error
object, take a look at the wp_login_errors
filter.
For more information on messages and their respective contexts, see the login
switch case in wp-login.php
Example:
Let’s say you want to remove the hyphens in ‘e-mail’ for any of the checkemail
context, because maybe you’re kind of a nut for AP Style. The following checks for the existence of ‘e-mail’ in the message string and replaces it with ’email’.
View the code example on Gist.
Have a suggested improvement? You can fork the Gist and comment back with the link. If all is agreeable, I’ll merge in your changes. Crowd-sourced documentation FTW!