Last active
October 14, 2017 17:01
-
-
Save gajayana/2d0b37b52526a5aa7781c5ddce6ae958 to your computer and use it in GitHub Desktop.
CMV #2
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
<?php | |
add_action( 'wp_ajax_add_notifier_email', 'add_notifier_email'); | |
function add_notifier_email() { | |
$post_id = (int)$_POST['company_id']; | |
$email = sanitize_email($_POST['email']); | |
if (is_numeric($post_id) && $email) { | |
$emails = get_field('email_notifiers', $post_id); | |
$emails[] = array( | |
'email' => $email, | |
); | |
update_field('email_notifiers', $emails, $post_id); | |
$res = array( | |
'status' => 'ok', | |
'message' => 'e-mail has been saved', | |
); | |
} else { | |
$res = array( | |
'status' => 'error', | |
'message' => 'Check company id and/or email', | |
); | |
} | |
echo json_encode($res); | |
wp_die(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment