Send an Email on ACF Form Submission

The following code emails a particular person whenever an ACF Form is submitted. It’s a slight modification of the example at the bottom of this page. Since I’m dealing with three forms with different fields, I do some if statements to gather and append various fields if they exist. In this particular workflow, all these post types end up in draft mode so I use get_edit_post_link to put the approver (the person getting this email) into the editor view rather than using get_the_permalink (which would take them to the preview). Since I wanted a bit more control, the email is also set to be HTML via the headers – $headers = array(‘Content-Type: text/html; charset=UTF-8’); And finally, is_admin() prevents the email from firing if you’re creating content in the normal editor zone rather than via the form. I am not a fan of the name of this function as I have forgotten and used it to try to see if someone is an editor (which it doesn’t do). Feels like it should be is_in_admin or something like that.