Change the default text of a WordPress registration error

Recently I was asked by a client to change the default wording of a WordPress registration error. The website had a popup login/registration plugin installed and the error message "Error: This email is already registered, please choose another one." was displayed when an existing customer entered their email address on the "New Account (new customers)" tab rather than the "Sign in for existing clients" tab. Apparently this was happening regularly and customers were getting confused and registering a second account with a different email address. So the decision was made to change the wording of the error message to "Your email is already registered. Sign in using the grey SIGN-IN tab top left. Thanks!" to make things a little clearer for customers.

Now you would think that this would be a simple task to complete.... wrong. That error message is part of the core WordPress code and there is nowhere in the settings to alter it. I have had to write a code filter to change it. Here is the code snippet:

add_filter('registration_errors', 'filter_registration_errors');
function filter_registration_errors($error){
   if ( $error->get_error_messages( 'email_exists' ) ) {
       $error = new WP_Error( 'email_exists', "Your email is already registered. Sign in using the grey SIGN-IN tab top left. Thanks!" );
   return $error;

You can add this code in either the functions.php file of your theme or use a plugin like Code Snippets which is what I did.

Leave a Reply

Your email address will not be published.

Firth Web Works ©2022 All Rights Reserved | Privacy Policy
Top homephoneenvelopechevron-downcross-circle linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram