Help: Unique meta key value & custom validate
-
Hello,
Is there a way to add extra validation to “Meta Key Unique Value” in the registration form?
I’m trying to couple meta key Unique Value validation with another custom validation, but I can’t find the solution.
I need users to register with their DNI (Identity Document in Spain) number only once, but also verify that this DNI is valid with the following custom validation.
/** * Validar campo DNI * @param string $key * @param attay $array * @param array $args */ function um_custom_validate_dni($key, $array, $args){ $letra = substr($args[$key], -1); $numeros = substr($args[$key], 0, -1); if ( isset( $args[$key]) && substr("TRWAGMYFPDXBNJZSQVHLCKE", $numeros%23, 1) == $letra && strlen($letra) == 1 && strlen ($numeros) == 8 ){ //UM()->form()->add_error( $key, __( 'DNI VALIDO.', 'ultimate-member' ) ); }else{ UM()->form()->add_error( $key, __( 'DNI INCORRECTO, utilice formato: Ocho números y letra mayúscula.', 'ultimate-member' ) ); } }
Would both things be possible? I’m sorry if I don’t explain myself well.
Thank you very much.
All the best.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Help: Unique meta key value & custom validate’ is closed to new replies.