I found a way to do it with the function that I will leave below
add_action( 'user_registration_validate_text','ur_validate_text_field',10,4);
function ur_validate_text_field($single_form_field, $data, $filter_hook, $form_id) {
global $wpdb;
$field_label = isset( $data->label ) ? $data->label : '';
$value = isset( $data->value ) ? $data->value : '';
if( 'YOUR_FIELD_NAME' === $single_form_field->general_setting->field_name ) {
if(1 != empty($value)) {
$res = $wpdb->get_var("SELECT * from wp_users us join wp_usermeta um on um.user_id = us.ID
where um.meta_key = 'user_registration_YOUR_FIELD_NAME' and um.meta_value = $value");
if( count($res) > 0 ) {
add_filter( $filter_hook, function ( $msg ) use ( $field_label ) {
return __( $field_label . 'There is already a user with this number registered.', 'user-registration' );
});
}
}
}
if( 'YOUR_FIELD_NAME' === $single_form_field->general_setting->field_name ) {
if(1 != empty($value)) {
if( 1 != ctype_digit($value) ) {
add_filter( $filter_hook, function ( $msg ) use ( $field_label ) {
return __( $field_label . 'The number field can only contain numbers.', 'user-registration' );
});
}
}
}
}