我有自定义后期类型。 如果用户可以满足此“需求”,则单击打开模态的按钮。 在模式中是提交按钮,该按钮将通过电子邮件发送给网站管理员,告诉他用户可以满足特定需求。
我想加载管理员电子邮件,用户电子邮件,需要标题和特定的网站名称(这是WPMU)。
我在模态框中完成了此操作,但如何将模态框信息输入电子邮件?
我已将模态编码为:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Fulfill this Need!</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" action="http://gogibb.com/wordpress/wp-content/themes/GoGibbChild/sendmail.php" method="post">
Thank you
<strong><?php global $current_user;
get_currentuserinfo();
echo $current_user->user_login . "\n";
?></strong>
for doing your part and helping others.<br/>
You are offering to fullfill a need:<br/><br/>
(<?php echo get_the_title($ID); ?>) from
<?php
$the_query = new WP_Query( array(
'post_type' => 'agency',
'orderby' => 'date',
'order' => 'DESC',
'posts_per_page' => '1')); // how many posts to show
// Put into the loop
while ( $the_query->have_posts() ) :
$the_query->the_post();
echo '<td><a href="' . get_permalink($post->ID) . '">' . get_the_title() . '</a></td></tr>';
endwhile;
// Restore original Post Data if needed
wp_reset_postdata(); ?>.<br/><br/>
Please add a little bit about yourself and why you'd like to fulfill the need. We'll get back to you very shortly.<br/>
<textarea class="fulfill-textarea"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" name="submit" class="btn btn-primary">Fulfill</button><br/><br/>
我的php邮件脚本如下。我知道的顶部部分不能正常工作,但我以一种方式将其写出来向您展示我需要的信息来自wordpress。任何帮助将不胜感激!
<?php
$adminemail = $_POST['adminemail'];
$currentusername = $_POST['currentusername'];
$useremail = $_POST['useremail'];
$currentneedtitle = $_POST['needtitle'];
$sitename = $_POST['sitename'];
$commentz = $_POST['commentz'];
$to = "$useremail";
$subject = "[$sitename] Someone wants to fulfill your need!";
$body = "$currentusername has fulfilled your need!<br><br>
$currentneedtitle on $sitename <br/><br/>
$commentz <br/><br/>
Email the user at $useremail today to get the process started.
";
$headers = "From: $adminemail" . "\r\n" .
"Reply-To: $to" . "\r\n" .
"X-Mailer: PHP/" . phpversion();
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to,$subject,$body,$headers);
header("location: http://www.waxbayouhuntingclub.com/wax/thank");
exit;
?>
答案 0 :(得分:0)
我通过隐藏输入字段中的所有动态数据并以与上面相同的方式传递它来修复此问题(我更改了一些var名称)。这是代码:
<input type="hidden" id="useremail" name="useremail" value="<?php global $current_user;
get_currentuserinfo();
echo $current_user->user_email . "\n";
?>">
<input type="hidden" id="adminemail" name="adminemail" value="<?php echo bloginfo('admin_email');?>">
<input type="hidden" id="needtitle" name="needtitle" value="<?php echo get_the_title($ID); ?>">
<input type="hidden" id="username" name="username" value="<?php global $current_user;
get_currentuserinfo();
echo $current_user->user_login . "\n";
?>">
<input type="hidden" id="sitename" name="sitename" value="<?php echo get_bloginfo('name'); ?>">