我有以下功能:
add_action('frm_after_create_entry', 'dmdSendTestKeyZGS', 30, 2);
function dmdSendTestKeyZGS($entry_id, $form_id){
global $wpdb;
if($form_id == 13){
global $wpdb;
$myrow = $wpdb->get_row( "SELECT * FROM mi_zgskeys WHERE used = 0", ARRAY_A);
$id = $myrow['id'];
$key = $myrow['key']; //KEY IS STORED
$wpdb->query("UPDATE mi_zgskeys SET used = 1 WHERE id = $id");
$body = get_email_body_wpse_96357($key);
$headers = array('Content-Type: text/html; charset=UTF-8');
if(isset($_POST['item_meta'][96]))
wp_mail($_POST['item_meta'][96], 'test', $body, $headers);
}
}
function get_email_body_wpse_96357($key) {
$body = "<!DOCTYPE html>
<html>
<head>
<meta charset=\"UTF-8\">
<title>Ihr Test-Lizenzschlüssel</title>
</head>
<body>
<div>
<div>
<p><a><?php echo $key; ?></p> //$key EMPTY???
</div>
</div>
</body>
</html>";
return $body;
}
有人可以告诉我为什么模板中的$key
为空吗?
如果我发送电子邮件,则该字段未填写且不确定原因。
答案 0 :(得分:0)
只需将 <?php echo $key; ?>
替换为 $key
。
http://php.net/manual/en/language.types.string.php#language.types.string.parsing