我正在尝试创建一个功能,在新用户注册时向管理员发送电子邮件。我希望电子邮件包含用户的名字、姓氏、电子邮件地址和通过WooCommerce添加的账单信息。这是我到目前为止所拥有的,但出于某种原因,$id和$email是电子邮件中显示的唯一变量,而不是其他变量。。我做错了什么?英雄联盟
function admin_notification($user_id) {
$user = get_userdata( $user_id );
$id = $user->id;
$email = $user->user_email;
$firstname = $user->first_name;
$lastname = $user->last_name;
$phone = get_user_meta($id, \'billing_phone\', true);
$address = get_user_meta($id, \'billing_address_1\', true);
$city = get_user_meta($id, \'billing_city\', true);
$state = get_user_meta($id, \'billing_state\', true);
$zip = get_user_meta($id, \'billing_postcode\', true);
$headers = array(\'Content-Type: text/html; charset=UTF-8\',\'From: My WordPress Site <[email protected]>\');
$message = \'<p>\'. $firstname .\' \'. $lastname .\' has requested registration to the website. Please verify their account as soon as possible.</p><hr /><p><strong>First Name:</strong> \'.$firstname.\'<br><strong>Last Name:</strong> \'.$lastname.\'<br><strong>Email Address:</strong> \'.$email.\'<br><strong>Phone Number:</strong> \'.$phone.\'<br><strong>Address:</strong><br>\'.$address.\', \'.$city.\' \'.$state.\' \'.$zip.\'</p><br><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="green" style="padding: 12px 18px 12px 18px; -webkit-border-radius:3px; border-radius:3px" align="center"><a href="https://example.com/wp-admin/user-edit.php?user_id=\'.$id.\'" target="_blank" style="font-size: 16px; font-family: Helvetica, Arial, sans-serif; font-weight: normal; color: #ffffff; text-decoration: none; display: inline-block;">Verify User</a></td></tr></table></td></tr></table>\';
wp_mail(\'[email protected]\', \'New Customer Registration\', $message, $headers);
}
add_action(\'user_register\', \'admin_notification\', 10, 1);