Php Wordpress报道一篇文章
大家好,我正在使用下面的代码制作一份报告张贴表单:Php Wordpress报道一篇文章,php,wordpress,Php,Wordpress,大家好,我正在使用下面的代码制作一份报告张贴表单: $rp_options = array( 'broring' => 'This is really boring', 'difficult' => 'I don\'t understand this', 'great' => 'Great stuff, need more' ); $mail_report_to = 'me@domain.com'); function createReportPost
$rp_options = array(
'broring' => 'This is really boring',
'difficult' => 'I don\'t understand this',
'great' => 'Great stuff, need more'
);
$mail_report_to = 'me@domain.com');
function createReportPostForm() {
global $rp_options, $post;
$html = '
<div id="formcont">
<h3>Report this article</h3>
<form id="myform">
<p>
<label for="name">What\'s wrong?</label>
<select name="report-msg" id="report-msg">
<option val="">...</option>';
foreach ($rp_options as $ok => $ov) {
$html .= '
<option val="'.$ok.'">'.$ov.'</option>';
}
$html .= '
</select>
<input type="hidden" name="posturl" value="'.get_permalink().'" />
<input type="hidden" name="action" value="ajax_action" />
<input type="button" value="Submit" id="submit_button" />
</p>
</form>
</div>
<div id="output"></div>';
return $html;
}
add_shortcode('rp-form', 'createReportPostForm');
$rp\u options=array(
“broring”=>“这太无聊了”,
“困难”=>“我不懂这个”,
“很棒”=>“很棒的东西,需要更多”
);
$mail\u report\u发送至me@domain.com');
函数createReportPostForm(){
全球$rp_选项,$post;
$html='1
报道这篇文章
怎么了?
...';
foreach($rp_选项为$ok=>$ov){
$html.='
“.$ov.”;
}
$html.='
';
返回$html;
}
添加_短代码('rp-form','createReportPostForm');
我收到了表格,但它没有发送邮件。有人能告诉我这段代码中遗漏了什么吗?谢谢您没有发送邮件。我看到的只是一个生成html表单并返回表单的函数。您还应该处理post本身,其中使用的是JavaScript和其他PHP,可以在您发送的链接中找到,它们对表单进行实际处理。您在这里发布的内容只添加了表单,根据您的说法,表单工作正常。是的,但在functions.php中,我也添加了所有javascript函数,但javascript不工作。我还更改了wp_enqueue_脚本('ajax script',plugin_dir_url(FILE)。'rp-script.js',array('jquery'),1.0);到wp_enqueue_script('ajax script',get_stylesheet_directory_uri()。/js/rp script.js',array('jquery'),1.0);但是没有什么比刚才把$mail\u report\u改成$mail更合适的了me@domain.com'); 使用此代码$mail\u report\u to=get\u选项('admin\u email');但是这也不起作用,可能是ajax中的问题提交按钮不可点击,所以我尝试将type=“submit”和表单操作添加到permalink中,但它不起作用