Nachdem ein Kontaktformular zu senden bekam ich folgende Fehlermeldung:WP: Kopf Warnung nach E-Mail zu senden
Warning: Cannot modify header information - headers already sent by (output started at /home/clientsc/public_html/mypage/wp-includes/general-template.php:2680) in /home/client/public_html/mypage/wp-includes/pluggable.php on line 1171
ich diesen Fehler habe, wenn ich die Funktion unten in der Datei functions.php
function send_my_awesome_form(){
if (!isset($_POST['submit'])) {
// get the info from the from the form
$form = array();
$form['fullname'] = $_POST['fullname'];
$form['company'] = $_POST['company'];
$form['email'] = $_POST['email'];
}
// Build the message
$message = "Name :" . $form['fullname'] ."\n";
$message .= "Company :" . $form['company'] ."\n";
$message .= "Email :" . $form['email'] ."\n";
//set the form headers
$headers = 'From: Contact form <[email protected]>';
// The email subject
$subject = 'you got mail';
// Who are we going to send this form too
$send_to = '[email protected]';
if (wp_mail($send_to, $subject, $message, $headers)) {
wp_redirect(home_url()); exit;
}
}
add_action('wp_head', 'send_my_awesome_form');
benannt setzen
Wie kann ich dieses Problem lösen?
Mögliche Duplikat von [Wie beheben "Header bereits gesendet" Fehler in PHP] (http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php) – Qirel