在某个动作之后,从Wordpress发送电子邮件的最佳方式是什么。
我在一个网站上工作,用户可以提交想法,然后其他用户可以对其发表评论。
我想在发帖和发表评论时,向多个不同的地址(版主)发送电子邮件。
我有这个代码来添加帖子,试图发送一封不起作用的电子邮件。
<section class="submitForm">
<h1>Submit idea</h1>
<?php
if(isset($_POST[\'new_post\']) == \'1\'){
$post_title = $_POST[\'post_title\'];
$post_content = $_POST[\'content\'];
$new_post = array(
\'ID\' => \'\',
\'post-author\' => $user->ID,
\'post_title\' => $post_title,
\'post_content\' => $post_content,
\'post_status\' => \'publish\'
);
$post_id = wp_insert_post($new_post);
$post = get_post($post_id);
wp_redirect($post->guid);
exit;
// send email notifications
wp_mail( \'[email protected]\', \'New Idea\', $post_content);
}
echo \'<form method="post" action="" >\';
echo \'<label for="idea_title">Idea Title</label>\';
echo \'<input type="text" name="post_title" class="title">\';
$settings = array(
\'quicktags\' => false,
\'textarea_name\' => \'content\',
\'media_buttons\' => true,
\'textarea_rows\' => 12,
\'tinymce\' => array(
\'theme_advanced_buttons1\' => \'formatselect,|,bold,italic,underline,|,\' .
\'bullist,blockquote,|,justifyleft,justifycenter\' .
\',justifyright,justifyfull,|,link,unlink,|\' .
\',spellchecker\'
)
);
wp_editor( \'\', \'content\', $settings );
echo \'<input type="hidden" name="new_post" value="1">\';
echo \'<input type="submit" class="submit" value="Submit Idea">\';
?>
</section>