Hi @ryanwebgrade,
Could you please refer to this doc to add custom validations to any fields programmatically : https://docs.wpuserregistration.com/docs/how-to-add-custom-validations-to-fields-programmatically/
Do let us know whether it helps for you or not and I will get back to you.
Regards!
Hi,
Yes I tried it, but I didn’t work for me. I would like a user to be able to register only with a work email, such as [email protected]. What do I have to adjust in the documentation?
https://processen.webgradeklant.nl/registreren/ In de field, “E-mailadres” I would like the validation, is that possible?
Kind Regards,
Ryan
Hi there,
Could you please use this code snippet to meet your requirements?
add_action( 'user_registration_validate_user_email', 'ur_validate_email_field', 10, 4 );
function ur_validate_email_field( $single_form_field, $data, $filter_hook, $form_id ) {
$field_label = isset( $data->label ) ? $data->label : '';
$value = isset( $data->value ) ? $data->value : '';
if ( 'user_email' === $single_form_field->general_setting->field_name ) {
if ( ! preg_match( '/@webgrade\b/', $value ) ) {
add_filter( $filter_hook, function ( $msg ) use ( $field_label ) {
return __( 'Please use a valid @webgrade email address.', 'user-registration' );
} );
}
}
}
To add code, could you please refer to this doc: https://docs.wpuserregistration.com/docs/how-to-add-the-custom-code-snippet-on-your-site/
Do let us know whether it works for you or not and I will get back to you.
Regards!
Hi,
It works, thank you very much!
Kind Regards,
Ryan
-
This reply was modified 2 years, 9 months ago by
ryanwebgrade.