php - 在注册表单中添加的额外字段将保存在 wp_users 表中,而不是 wp_usermeta 表(WooCommerce)
问题描述
我在注册表中添加了额外的字段。代码如下:
function wooc_extra_register_fields() {
?>
<p class="form-row form-row-first">
<label for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?><span class="required">*</span></label>
<input type="text" class="input-text" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
</p>
<p class="form-row form-row-last">
<label for="reg_billing_last_name"><?php _e( 'Last name', 'woocommerce' ); ?><span class="required">*</span></label>
<input type="text" class="input-text" name="billing_last_name" id="reg_billing_last_name" value="<?php if ( ! empty( $_POST['billing_last_name'] ) ) esc_attr_e( $_POST['billing_last_name'] ); ?>" />
</p>
<div class="clear"></div>
<p class="form-row form-row-wide">
<label for="reg_billing_phone"><?php _e( 'Mobile Phone No.', 'woocommerce' ); ?><span class="required">*</span></label>
<input type="text" class="input-text" name="billing_phone" id="reg_billing_phone" value="<?php esc_attr_e( $_POST['billing_phone'] ); ?>" />
</p>
<?php
}
add_action( 'woocommerce_register_form_start', 'wooc_extra_register_fields' );
现在我希望这些字段在 wp-user 数据库中可见,以便可以在一个地方看到所有用户数据,而不是切换到用户元数据来查看额外的字段数据。有什么办法吗?
如果我必须添加一个额外的数据库,那该怎么办?
解决方案
推荐阅读
- c# - 在后台运行函数,同时保持 UI 可交互 C# Xamarin
- python-3.x - 如何使用逗号分隔存储 JSON 数据帧
- java - 使用 supportFragmentManager 推送新的 Fragment
- python - 导入其他python文件时python中没有属性错误
- python - Pandas 条形图轴
- java - 将输出重定向到 Java 中的 JTextArea 时出错
- python - 使用 .bat 文件运行 .py 脚本时,%* 修饰符的实际用途是什么?
- java - 如何使 Android 应用程序在安装时有一个包含图像的文件夹?
- android - 将协程与片段一起使用的最佳实践是什么?
- entity-framework - 尝试迁移 datatimeoffset 时,带有 EF 的 SQL Server CE 导致错误