Hello,
All the additional fields are passed with all the prerequisites validations. If you need custom validation or validation for your customly created field, you can use this action hook user_registration_validate_{field_key}. For example the following codes will validate the number below 10.
function ur_validate_number( $field, $form_data, $filter_hook, $form_id ) {
$field_label = isset( $form_data->label ) ? $form_data->label : '';
$value = isset( $form_data->value ) ? $form_data->value : '';
if( $value < 10 ) {
add_filter( $filter_hook, function ( $msg ) use ( $field_label ) {
return __( $field_label . ' must be greater than 10.', 'user-registration' );
});
}
}
add_action( 'user_registration_validate_number', 'ur_validate_number', 10, 4 );
Hello,
I ran tests by replacing the number with the id of the “user_registration_validate_number” -> “user_registration_validate_input_box_1551445019” field, but I was not successful.
{Field_key} is the field id?
Hello,
You have to use field_key. Field_Key is not field_id. The field_key for input is text.
Use like this user_registration_validate_text.
Thanks.