【问题标题】:Saving custom fields and mailing to the WooCommerce administrator保存自定义字段并邮寄给 WooCommerce 管理员
【发布时间】:2019-02-28 14:05:40
【问题描述】:

我使用“高级自定义字段”和“ACF for WooCommerce”插件。我创建了几个自定义字段并将它们放在“编辑帐户”页面上。

如果用户更改此页面上的个人信息,我需要收到一封包含这些自定义字段值的电子邮件。

为此,我下载了由@helgatheviking - WooCommerce trigger custom email via AJAX编写的测试插件

我有这些字段的输出代码,例如:

get_field( 'user_phone', "user_{$user_id}" );

如何正确的把这段代码放到插件里面,让这些自定义字段的数据到管理员那里?

如何将“电子邮件触发器”按钮与自定义字段结合起来,使字段数据存储在数据库中并同时发送给管理员?

我会很高兴你的帮助!

【问题讨论】:

    标签: php wordpress email woocommerce advanced-custom-fields


    【解决方案1】:

    您可以使用profile_update 挂钩并创建自定义函数以通过电子邮件发送自定义字段数据。这些方面的东西应该起作用。注意get_field() 函数中$user_id 变量的格式。

    function my_custom_function( $user_id ) {
    
        $phone = get_field( 'user_phone', 'user_'.$user_id );
    
        // Get the rest of your field values, format them together however you want, then use wp_mail() to send the email
    
    }
    add_action( 'profile_update', 'my_custom_function');
    

    【讨论】:

      猜你喜欢
      • 2021-07-15
      • 2018-02-07
      • 1970-01-01
      • 2023-03-27
      • 2016-07-28
      • 2020-11-26
      • 1970-01-01
      • 2020-03-11
      • 2021-04-12
      相关资源
      最近更新 更多