Create custom validation for registration fields programmatically
-
I followed the documentation and another answer here about using your specific hooks to define custom validation, it worked with “user_registration_validate_user_email” but once I change it to “user_registration_validate_[field_name]” it won’t work, is it specific for email and username only ?
// add_action( ‘user_registration_validate_number_box_1605799382′,’ur_validate_number_box_1605799382_field’,10,4);
// function ur_validate_number_box_1605799382_field($single_form_field, $data, $filter_hook, $form_id) {
// $field_label = isset( $data->label ) ? $data->label : ”;
// $value = isset( $data->value ) ? $data->value : ”;// if( condition ) {
// add_filter( $filter_hook, function ( $msg ) use ( $field_label ) {
// return __( $field_label . ‘Please enter a valid number.’, ‘user-registration’ );
// });
// }
// }
The topic ‘Create custom validation for registration fields programmatically’ is closed to new replies.