• Resolved tekwarr

    (@tekwarr)


    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)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @tekwarr

    Please follow this documentation to add custom validation to a form.

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Hey there!

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. 🙂

    Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help: Unique meta key value & custom validate’ is closed to new replies.