Last active
June 18, 2025 06:37
-
-
Save yuriinalivaiko/11e0530f4329b63e817b844b3fd9320f to your computer and use it in GitHub Desktop.
Ultimate Member customization. Change error message for the "E-mail Address" field in the Registration form.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom validation and error message for the "E-mail Address" field. | |
*/ | |
add_action( 'um_custom_field_validation_user_email_details', 'um_custom_validate_user_email_details', 999, 3 ); | |
function um_custom_validate_user_email_details( $key, $array, $args ) { | |
if ( $key == 'user_email' && isset( $args['user_email'] ) ) { | |
if ( isset( UM()->form()->errors['user_email'] ) ) { | |
unset( UM()->form()->errors['user_email'] ); | |
} | |
if ( empty( $args['user_email'] ) ) { | |
UM()->form()->add_error( 'user_email', __( 'E-mail Address is required', 'ultimate-member' ) ); | |
} elseif ( ! is_email( $args['user_email'] ) ) { | |
UM()->form()->add_error( 'user_email', __( 'The email you entered is invalid', 'ultimate-member' ) ); | |
} elseif ( email_exists( $args['user_email'] ) ) { | |
UM()->form()->add_error( 'user_email', __( 'The email you entered is already registered', 'ultimate-member' ) ); | |
} | |
} | |
} |
I got a problem with last elseif ( email_exists( $args['user_email'] ) )
I already has email in DB but got message - "The email you entered is invalid"
elseif ( ! is_email( $args['user_email'] ) ) {
UM()->form()->add_error( 'user_email', __( 'The email you entered is invalid', 'ultimate-member' ) );
}
not working
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the Custom Validation option to change the error message for the E-mail Address field in the Registration form. The custom_field_validation_user_email.php code snippet is an example for validation based on the Custom Validation option.
See articles Fields Validation and Custom validation email and error message in registration for details.