- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的特殊问题是将名字和姓氏添加到客户的新帐户电子邮件中,为此我尝试了各种方法。最终,我最终查看了 Codex,因为 woocommerce 注册详细信息已保存为用户帐户。问题似乎是 Woocommerce 在用户登录之前发送了新客户电子邮件 - 尽管我可能在这里遗漏了一些东西?这是最后尝试的方法,但它在用户 ID 中产生 0,基本上用户未登录,因此我之前的评论。这是我正在使用的代码合并到默认的 woocommerce 模板中...
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?>
<?php do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<?php
$current_user = wp_get_current_user();
/**
* Get current logged in user detail from codex
*/
echo 'Username: ' . $current_user->user_login . '<br />';
echo 'User email: ' . $current_user->user_email . '<br />';
echo 'User first name: ' . $current_user->user_firstname . '<br />';
echo 'User last name: ' . $current_user->user_lastname . '<br />';
echo 'User display name: ' . $current_user->display_name . '<br />';
echo 'User ID: ' . $current_user->ID . '<br />';
?>
<!--<img src = "image-name" style="margin-right:0px;">-->
<h3 style="text-align:center;" ><?php echo 'Hi '. $current_user->user_firstname . ', welcome to.'; ?></h3>
<p style="text-align:center;" >Thanks for signing up to our online service.</p>
<h4 style="text-align:center; color:#289b38; ">Getting in touch with us.</h4>
<p style="text-align:center;"><?php printf( __( 'Contact us by phone on: %1$s, or by email to %2$s'), '<strong style="color:#289b38;">0999 999 999</strong>', '<strong><a href="mailto:someone@something.com">someone@something.com</a></strong>' ); ?></h4>
<h4 style="text-align:center; color:#2f51a8;">Your account details.</h4>
<p style="text-align:center;" ><?php printf( __( 'Thanks for creating an account on %1$s. Your username is %2$s', 'woocommerce' ), esc_html( $blogname ), '<strong>' . esc_html( $user_login ) . '</strong>' ); ?></p>
<?php if ( 'yes' === get_option( 'woocommerce_registration_generate_password' ) && $password_generated ) : ?>
<p style="text-align:center;" ><?php printf( __( 'Your password has been automatically generated: %s', 'woocommerce' ), '<strong>' . esc_html( $user_pass ) . '</strong>' ); ?></p>
<?php endif; ?>
<p style="text-align:center;" ><?php printf( __( 'You can access your account area to view your orders and change your password here: %s.', 'woocommerce' ), make_clickable( esc_url( wc_get_page_permalink( 'myaccount' ) ) ) ); ?></p>
<p style="text-align:center;" >Best wishes<p>
<p style="text-align:center;" >Company name</p>
<br>
<?php do_action( 'woocommerce_email_footer', $email );
最佳答案
您无法获取当前用户,因为它不是前端 Hook 。而是作为变量 $user_login
是在这个模板中定义的,你可以用它来获取WP_User
对象替换:
$current_user = wp_get_current_user();
$current_user = get_user_by('login', $user_login );
emails/customer-new-account.php
模板文件。所以现在您将能够显示名字和姓氏,
如果它们作为用户元数据存在 ,使用以下代码插入此模板:
<?php $user = get_user_by('login', $user_login ); ?>
<p><?php
_e('First name'); ?>: <?php echo $user->first_name; ?><br /><?php
_e('First name'); ?>: <?php echo $user->last_name;
?></p>
关于php - 将名字和姓氏添加到 Woocommerce 中的新帐户电子邮件通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52079041/
我有两个表,Table1和Table2。 Table1由格式为FullName的名称列('FirstName LastName')和唯一标识符(Key)组成。 Table2的列(Name)由这些名称组
我正在使用 ajax 实时搜索来选择名称和姓氏的串联与输入的文本匹配的所有用户,并且效果很好: $sql = "SELECT * FROM users WHERE concat(name,' ',su
我有一组采用 last, first 格式的名称 Name Pos Team Week.x Year.x GID.x h.a.x Oppt.x Week1Points DK.
我有一个函数,如果我有姓氏和名字,它应该返回 True。 此名称返回 False,但应返回 True。任何想法为什么?我希望能够在名称 A-Z、a-z、下划线和 0-9 中接受撇号。逗号前后可能有也可
我有一个 drupal 数据库,其中 node 表充满了配置文件。字段node.title是“Firstname Lastname”。我想分隔名称,以便 node.title = "Firstname
我正在使用 Django-Registration 包让用户创建帐户、对其进行身份验证并登录到我的 web 应用程序。 但是,用于创建帐户的表单/ View 不会要求用户提供名字/姓氏(这些字段是模型
我正在尝试使用云工具包获取用户的名字,但是以下代码未获取用户的名字,并且将firstNameFromFunction变量保留为空。有谁知道如何在iOS 10中实现这一目标? let container
运行应用程序时出现以下错误: 错误: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'pa
我想尝试在 Javascript 中检测一个人名字的不同部分,并将它们剪掉,以便我可以将它们传递给其他东西。 名称可以以任何格式出现——例如:- 维多利亚·米·莱恩小姐 Victoria C J Lo
这是我读过的教程中的查询 CREATE TABLE Employee ( id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, depa
所以我的程序有问题。如果我删除 in.nextLine,println 的名字和姓氏将一个接一个地打印,如果我有它,它不会在我的输出中打印名字,因为我认为它正在删除它。任何帮助将不胜感激。 impor
我专门使用omniauth来允许使用facebook/google/twitter登录到我的网站。 我存储名字,姓氏和电子邮件。但是,当我从oauth引发twitter auth哈希时,我仅在auth
我有一个看起来有点像这样的 df: name id John McNamara 3498 Jane Adams,
我有一个大数据集,我知道其中包含许多重复记录。基本上我有关于名字、姓氏、不同地址组成部分和出生日期的数据。 我认为最好的方法是使用姓名和出生日期,因为如果这些都匹配,则很可能是同一个人。可能有很多情况
我知道这是一件非常简单的事情,但我无法弄清楚我遗漏了什么或做错了什么。我认为这可能与 char 变量有关。这是我到目前为止所拥有的: #include #include "stdafx.h" #inc
我正在尝试使用以下代码获取电话联系人中所有可用联系人的详细信息。但面临重复值的小问题。 已编辑 实际代码开始:- private String refreshData() { Stri
我正在尝试实现对数据表的搜索。现在,我只能搜索名字、中间名和姓氏等。但是,在搜索全名(中间名和姓氏)时,搜索将不起作用。图像: success search for firtname/middle/l
Magento 是否可以通过客户的公司名称以及联系人姓名来查看/管理我们的客户,以便轻松找到他们?它用于 B2B,因此当电子邮件发出时,他们会提取客户的姓名,而不是更合适的公司名称。 这是全局设置吗?
我正在尝试实现对数据表的搜索。现在,我只能搜索名字、中间名和姓氏等。但是,在搜索全名(中间名和姓氏)时,搜索将不起作用。图像: success search for firtname/middle/l
我想检查用户输入的命令如: 添加人员关系人员(人员可以是例如 John 或“John Smith”) 示例:添加 John Smith 兄弟 Jack Smith... 我使用分隔符(空格)将字符串拆
我是一名优秀的程序员,十分优秀!