php - 将 WordPress 用户后端中创建的附加字段添加到 woocommerce admin-new-order 电子邮件
问题描述
我在下面的代码中创建了一个附加字段,它是我们用来识别客户的内部参考。它由管理员在 WordPress 后端输入,对客户不可见。该字段工作正常,并保存输入该字段的数据。我的问题和我苦苦挣扎的地方是,当客户下订单时,我需要此字段出现在来自 woocomm 的 admin-new-order 电子邮件中。这必须适用于所有下订单的客户。尝试了多种方法,但我无法让该字段出现在电子邮件中,以便管理员可以在下新订单时参考。客户都首先获得批准,并在他们被允许下订单之前将参考添加到他们的个人资料中
您的帮助和意见将不胜感激
//** Internal Reference **//
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) { ?>
<h3>Extra profile information</h3>
<table class="form-table">
<tr>
<th><label for="int_ref">Internal Reference</label></th>
<td>
<input type="text" name="int_ref" id="int_ref" value="<?php echo esc_attr(
get_the_author_meta( 'int_ref', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
</table>
<?php }
add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );
function my_save_extra_profile_fields( $user_id ) {
update_usermeta( $user_id, 'int_ref', sanitize_text_field( $_POST['int_ref']) );
}
解决方案
推荐阅读
- xamarin - 在 Xamarin 表单中的屏幕截图上应用水印
- javascript - 在没有nodejs的js中制作视频聊天应用
- gstreamer - glimagesink render-rectangle 无法在代码中设置
- c++ - 如何从 curl 多句柄 c++ libcurl 返回响应
- python - 如何将 QListWidget setText 位置更改为顶部?
- c++ - 在可变参数类模板中调用可变参数成员函数模板时,gcc 和 clang 的行为不同
- r - 从 reshape2 包运行 melt 功能时,代码卡在日志中
- amazon-web-services - Github Actions CI/CD 部署到 AWS 的最佳安全实践
- javascript - 将 HTML/PHP 加载到 JQuery 选项卡中
- python - Ctypes,将指针传递给枚举,接收 uint_32