【问题标题】:Add user´s Bio in woocommerce email notifications在 woocommerce 电子邮件通知中添加用户的简历
【发布时间】:2018-04-23 13:58:46
【问题描述】:

在我的 WooCommerce 网站中,我正在尝试添加用户传记。

关于如何在 Woocommerce 电子邮件通知中添加用户的简历有什么想法吗?

【问题讨论】:

  • 不,这不是自定义字段。这是经典的用户简历。我发现了一些关于函数 get_user_meta(´description´) 的内容,但我无法安排它。

标签: php wordpress woocommerce user-data email-notifications


【解决方案1】:

woocommerce_email_customer_details 动作挂钩中尝试这个自定义挂钩函数:

add_action ('woocommerce_email_customer_details', 'add_user_bio', 9, 4);
function add_user_bio( $order, $sent_to_admin, $plain_text, $email ){
    $user_bio = get_user_meta( $order->get_customer_id(), 'description', true );
    $title = __("Biographical Info","woocommerce");

    if( empty($user_bio) ) return; // We exit if the user bio doesn't exist

    echo '<table id="user-bio" cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top; margin-bottom: 40px; padding: 0;" border="0">
        <tbody>
            <tr>
                <td style="text-align:left; border: 0; padding: 0;" valign="top" width="100%">
                    <h2 style="color: #557da1; display: block; font-family: &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-size: 18px; font-weight: bold; line-height: 130%; margin: 0 0 18px; text-align: left;">'.$title.'</h2>
                </td>
            </tr>
            <tr>
                <td style="text-align:left; border: 0; padding: 0"  valign="top" width="100%">
                    <span style="border:solid 2px #e4e4e4; padding:12px; display:block;">'.$user_bio.'</p>
                </td>
            </tr>
        </tbody>
    </table>';
}

代码进入您的活动子主题(或主题)的 function.php 文件或任何插件文件中。

这是经过测试并且有效的。你会得到类似的东西:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-22
    • 1970-01-01
    • 2022-11-10
    • 2018-09-21
    • 1970-01-01
    • 1970-01-01
    • 2020-10-03
    • 1970-01-01
    相关资源
    最近更新 更多