在woocommerce客户注册中,我需要添加2个额外的字段(必填)通过年份(选择框),大学名称(选择框)。
我需要将这两个字段添加到注册过程中,并在尝试登录时提示现有用户填写它们。
在过程中将如下
提前致谢
答案 0 :(得分:0)
是的,可以做到。 据我了解,您想在注册页面添加一些额外的字段。以下是:
add_action( 'register_form', 'myplugin_register_form' );
function myplugin_register_form() {
$first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( $_POST['first_name'] ) : '';
?>
<p>
<label for="first_name"><?php _e( 'Full Name', 'mydomain' ) ?><br />
<input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr( wp_unslash( $first_name ) ); ?>" size="25" required /></label>
</p>
<?php
}
将代码放在function.php中,然后就可以了。 它会完美地运作。