Created
June 3, 2021 20:35
-
-
Save mager19/48f90bc7f0160ab951f506729462fbd3 to your computer and use it in GitHub Desktop.
send email on time check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('gform_after_submission', 'set_post_content', 10, 2); | |
function set_post_content($entry, $form) | |
{ | |
//vars | |
$id = $entry['form_id']; | |
if ($id == '3' || $id == '1' || $id == '10' || $id == '16') { | |
$date = new DateTime(); | |
$date->setTimezone(new DateTimeZone('America/Chicago')); | |
// $date->setTimezone(new DateTimeZone('Pacific/Apia')); | |
$hour = $date->format('H'); | |
if ($hour >= '17' && $hour <= '23' || $hour >= '00' && $hour <= '08') { | |
foreach ($form['fields'] as $field) { | |
$inputs = $field->get_entry_inputs(); | |
if (is_array($inputs)) { | |
foreach ($inputs as $input) { | |
if ($input['label'] == "First") { | |
// $value = array( | |
// $input['label'] => rgar($entry, (string) $input['id']) | |
// ); | |
$fname = rgar($entry, (string) $input['id']); | |
} | |
} | |
} else { | |
if ($field['label'] == 'Email') { | |
$email = rgar($entry, (string) $field->id); | |
} | |
} | |
} | |
$name = $fname; | |
$to = $email; | |
$subject = 'Our Team is Ready to Help | Contact Hotline for Immediate Assistance.'; | |
$body = ' | |
<h3>Hello ' . $name . ' </h3> | |
<p>Thank you for contacting J.C. Restoration! If you need assistance between the hours of 5:00pm and 8:00am CST, please call our 24/7/365 number at <a href="tel:800-956-8844">(800) 956-8844</a> to be connected to someone right away. Otherwise, you may hear from our office after 8:00am.</p> | |
<p>Sincerely,<br/> | |
J.C. Restoration Support Team</p><br/> | |
'; | |
$headers = array('Content-Type: text/html; charset=UTF-8', 'From: J.C. Restoration, Inc <[email protected]>'); | |
wp_mail($to, $subject, $body, $headers); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment