Several custom validations to a field
-
Hello, im using this code (provided by UM here https://docs.ultimatemember.com/article/94-apply-custom-validation-to-a-field) to allow users to register only if they have a unique key (TEST_VALUE in this example):
/**
* Validate field T2N_Code
* @param string $key
* @param attay $array
* @param array $args
*/
function um_custom_validate_username( $key, $array, $args ) {
if ( isset( $args[$key] ) && $args[$key] !== ‘TEST_VALUE’ ) {
UM()->form()->add_error( $key, __( ‘Please enter valid code.’, ‘ultimate-member’ ) );
}
}
add_action( ‘um_custom_field_validation_T2N_Code’, ‘um_custom_validate_username’, 30, 3 );Is it possible to have several keys accepted and not only one? How would that code look like?
- The topic ‘Several custom validations to a field’ is closed to new replies.