• Hi, when a user changes his email address in Account Page, and that the new email has already been taken by another user, message prompted “Please provide a valid email”. Can we change the validation message to “The email is already registered”?

Viewing 2 replies - 1 through 2 (of 2 total)
  • missveronica

    (@missveronicatv)

    @enkoes

    Yes, you can try this code snippet and change the error message

    add_filter( 'um_submit_form_error', 'um_submit_form_error_account_email', 10, 2 );
    function um_submit_form_error_account_email( $error, $key ) {
    
        if ( $key == 'user_email' && $error == __( 'Please provide a valid email', 'ultimate-member' ) ) {
            if ( isset( $_POST['user_email'] )) {
                $user_email = sanitize_text_field( $_POST['user_email'] );
                if ( email_exists( $user_email ) && email_exists( $user_email ) !== get_current_user_id() ) {
                    $error = 'The email is already registered';
                }
            }
        }
        return $error;
    }

    Install by adding the code snippet to your active theme’s functions.php file
    or use the “Code Snippets” Plugin

    https://www.ads-software.com/plugins/code-snippets/

    Thread Starter enkoes

    (@enkoes)

    Thanks! @missveronicatv

    It works beautifully.

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.