【发布时间】:2018-02-08 23:25:18
【问题描述】:
实际上我想做的是我想将自定义字段值发送到电子邮件。
我创建了一个帖子类型的简单表单,该表单仅在前端显示,用户可以在那里输入电子邮件和电话号码。提交后,一封邮件发送给网站所有者,一封邮件发送给企业所有者,另一封邮件发送给该特定用户的电子邮件 ID。
三封邮件内容不同
现在问题是
当我提交它时,没有。每个人收到的邮件数量等于没有。帖子数 例如,我有 3 个帖子,当我点击一个项目并提交时,它会发送所有项目的详细信息。我想限制一个。
站点所有者和企业所有者获取正确的信息,但最终用户无法获取自定义字段值,并且自定义字段来自高级自定义字段插件。
有谁能解决这些问题吗?
谢谢
这里是代码
<div class="column one">
<?php $pack= new WP_Query(array('post_type'=>'packer'));?>
<?php while($pack-> have_posts()): $pack->the_post();?>
<?php
$post = get_post( $post );
$title = isset( $post->post_title ) ? $post->post_title : '';
$usermail=$_POST['email'];
$cellno=$_POST['cellno'];
$phone=the_field('phone');
$pdesc=the_field('description');
if(isset($usermail) && isset($cellno)){
$to = 'siteowner@site.com';
$subject = 'New Enqiry for'. $title;
$body ="The enquiry for $title <br>Customer email is: $usermail<br> Customer Phone is: $cellno";
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $to, $subject, $body, $headers );
$to = 'businessowner@business.co.in';
$subject = 'New Customer Enquiry';
$body ="The enquiry by $usermail <br>Cellno is: $cellno";
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $to, $subject, $body, $headers );
$to = $usermail;
$subject = 'Details For $title';
$body ="Phone $phone <br>Desc is: $pdesc";
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $to, $subject, $body, $headers );
}
?>
<div class="column one-fourth">
<h1><?= the_title();?></h1>
<?php $post_id= get_post()->ID;?>
<img src="<?php the_field('logo');?>" />
<a href="#desc-<?= $post_id;?>" class="fancybox">
<input type="button" name="Details" value="DON'T PRESS THIS BUTTON"/>
</a>
<div style="display:none" class="fancybox-hidden">
<div id="desc-<?= $post_id;?>">
<?php the_field('description');?>
<?php the_field('phone');?>
<form action="" method="POST">
<input type="text" placeholder="Phone" name="cellno" id="cellno">
<input type="email" placeholder="Email" name="email" id="email">
<input type="submit" value="Send" name="send" id="send">
</form>
</div>
</div>
</div>
<?php endwhile; ?>
【问题讨论】: