Reputation: 31
I am using ACF options to save and email address for contact forms. Using Wordpress multi-site I can set who I want the forms to go to through the options panel. The form is sending out the auto responder, but it is not submitting to the saved email address.
<?php
$contact_form_email = get_field('contact_form_email','options');
$cyber_to = array($contact_form_email);
# CyberMark Subject Line
$cyber_subject = $s." Form Submission";
# Headers of email
$cyber_headers = "From: " . strip_tags('[email protected]') . "\r\n";
$cyber_headers .= "MIME-Version: 1.0" . "\r\n";
$cyber_headers .= "Content-Type: text/html; charset=ISO-8859-1" . "\r\n";
# CyberMark message
$cyber_msg = '<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Name:</td>
<td style="margin-left: 5px;">'.$n.'</td>
</tr>
<tr>
<td>Email:</td>
<td style="margin-left: 5px;">'.$e.'</td>
</tr>
<tr>
<td>Phone:</td>
<td style="margin-left: 5px;">'.$t.'</td>
</tr>
<tr>
<td>Message:</td>
<td style="margin-left: 5px;">'.$m.'</td>
</tr>
</table>';
# Loop through all email recipients
foreach($cyber_to as $cyber_email)
{
mail($cyber_email,$cyber_subject,$cyber_msg,$cyber_headers);
}
?>
Upvotes: 1
Views: 156
Reputation: 81
I guess from your problem that the PHP file processing the form is just inside a WP folder, its not really running within wordpress "ambient".
You need to actually load WP inside the file like this:
require($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');
This will load everything-wordpress for you to use in that file, including get_field(). ;)
Upvotes: 1