//Add phone number field to customer registration
add_filter( ‘register_form’, ‘custom_phone_no_registration_field’ );
function custom_phone_no_registration_field( ) {
echo ”.__(‘Phone Number’, ‘woocommerce’).’ *
‘;

}

//Validation registration form after submission using the filter registration_errors
add_action(‘registration_errors’, ‘custom_registration_errors_validation’, 10,3);
function custom_registration_errors_validation($reg_errors, $sanitized_user_login, $user_email) {
global $woocommerce;
extract($_POST); // extracting $_POST into separate variables
if(empty($phone)) :
$woocommerce->add_error( __( ‘Please, fill in all the required fields.’, ‘woocommerce’ ) );
endif;
return $reg_errors;
}

I’m using register_form function to add a phone number field to registration form.it works but the registration_errors function is not working. Can anyone please help me with the code ?

Read more here: Custom registration fields in woocommerce not validating


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: