admin管理员组文章数量:1419216
I have created a custom php form and on its submission email is sent to user but i want to send email to admin as well to keep admin up-to-date about form submissions on website using wp_mail.
<form action="<?php echo get_permalink() ?>" method="post" enctype="multipart/form-data">
<input type="text" name="ch_name" placeholder="Name*" value="" required>
<input type="text" name="ch_phone_num" placeholder="Phone*" value="" required>
<input type="email" name="ch_email" placeholder="Email*" value="" required>
<input type="text" name="ch_company" placeholder="Company*" value="" required>
<input type="text" name="ch_job_title" placeholder="Job Title*" value="" required>
<input type="file" name="upload" value="">
<input type="submit" name="submit" id="submitted">
</form>
And processing it:
if(isset($_POST['submit'])) {
$ch_name = $_POST['ch_f_name'];
$ch_phone_num = $_POST['ch_phone_num'];
$ch_email = $_POST['ch_email'];
$ch_company = $_POST['ch_company'];
$ch_job_title = $_POST['ch_job_title'];
$to = $ch_email;
$subject = "Thank you for job Submission ";
$content = "'.$ch_name.'";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Job Post at [email protected]' .
wp_mail($to,$subject,$content,$headers);
}
I have created a custom php form and on its submission email is sent to user but i want to send email to admin as well to keep admin up-to-date about form submissions on website using wp_mail.
<form action="<?php echo get_permalink() ?>" method="post" enctype="multipart/form-data">
<input type="text" name="ch_name" placeholder="Name*" value="" required>
<input type="text" name="ch_phone_num" placeholder="Phone*" value="" required>
<input type="email" name="ch_email" placeholder="Email*" value="" required>
<input type="text" name="ch_company" placeholder="Company*" value="" required>
<input type="text" name="ch_job_title" placeholder="Job Title*" value="" required>
<input type="file" name="upload" value="">
<input type="submit" name="submit" id="submitted">
</form>
And processing it:
if(isset($_POST['submit'])) {
$ch_name = $_POST['ch_f_name'];
$ch_phone_num = $_POST['ch_phone_num'];
$ch_email = $_POST['ch_email'];
$ch_company = $_POST['ch_company'];
$ch_job_title = $_POST['ch_job_title'];
$to = $ch_email;
$subject = "Thank you for job Submission ";
$content = "'.$ch_name.'";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Job Post at [email protected]' .
wp_mail($to,$subject,$content,$headers);
}
Share
Improve this question
edited Dec 5, 2018 at 22:28
Krzysiek Dróżdż
25.6k9 gold badges53 silver badges74 bronze badges
asked Dec 5, 2018 at 22:05
Wish CodexWish Codex
134 bronze badges
4
- Hi. Thanks for your question. Could you update it and post your code? It will make helping you a lot easier :) – Krzysiek Dróżdż Commented Dec 5, 2018 at 22:08
- @KrzysiekDróżdż i have updated my question please have a look – Wish Codex Commented Dec 5, 2018 at 22:25
- Great, thanks. Should both emails be the same? – Krzysiek Dróżdż Commented Dec 5, 2018 at 22:27
- Nope, Both emails have different content one for admin(It contains a message to notify admin new user submitted form on website) and other one for user – Wish Codex Commented Dec 5, 2018 at 22:29
1 Answer
Reset to default 0OK, so all you need to do is to add code for second email in the same place:
if ( isset( $_POST['submit']) ) {
$ch_name = $_POST['ch_f_name'];
$ch_phone_num = $_POST['ch_phone_num'];
$ch_email = $_POST['ch_email'];
$ch_company = $_POST['ch_company'];
$ch_job_title = $_POST['ch_job_title'];
$to = $ch_email;
$subject = "Thank you for job Submission ";
$content = "'.$ch_name.'";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Job Post at [email protected]' . "\r\n";
wp_mail( $to, $subject, $content, $headers );
// And here goes second email:
$admin_email = get_option( 'admin_email' );
$headers = 'From: Job Post at [email protected]' . "\r\n";
wp_mail(
$admin_email,
'Subject of second email',
'Message content',
$headers
);
}
本文标签: wp mailOn form submission how to send 2 email to different users
版权声明:本文标题:wp mail - On form submission how to send 2 email to different users 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745297194a2652151.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论