您可以使用woocommerce_registration_errors 钩子以验证用户名(&H);如果您的条件不满足,请设置一个错误-WooCommerce将退出并将错误传递回用户的UI:
add_filter( \'woocommerce_registration_errors\', function ( WP_Error $errors, $username ) {
if ( ! preg_match( \'/[a-z]/i\', $username ) ) {
$errors->add( \'username\', \'Username must contain alphabetic characters.\' );
}
return $errors;
}, 10, 2 );