0
//Add phone number field to customer registration
add_filter('register_form', 'custom_phone_no_registration_field');
function custom_phone_no_registration_field() {
echo '<div class="form-row form-row-wide"><label for="reg_phone">'.__('Phone Number', 'woocommerce').' <span class="required">*</span></label>
<input type="text" class="input-text" name="phone" id="reg_phone" size="30" value="'.esc_attr($_POST['phone']).'" /></div>';
}
//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;
}
我使用register_form中功能的電話號碼字段添加到註冊form.it工作,但是registration_errors功能無法正常工作。任何人都可以請幫助我的代碼?在woocommerce自定義記錄域沒有驗證