Home › Forums › General Issues › wp_mail not working in acf/pre_save_post › Reply To: wp_mail not working in acf/pre_save_post
First, you are inserting meta values when inserting a post incorrectly, see this https://wordpress.stackexchange.com/questions/218131/wp-insert-post-add-meta-input
Second, acf/pre_save_post runs before ACF has updated any values, these lines are probably returning nothing.
$name = get_field('post_title', $post_id);
$email = get_field('email', $post_id);
$body_text = get_field('email_tekst', 'option');
no email is sent because $email has no value?
another issue could be the post ID you set when calling acf_form. Does it match
if( $post_id != 'new_post' ) {
You should probably be using an acf/save_post action here rather than an acf/pre_save_post action.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
ACF PRO’s Flexible Content field allows you to create smaller pieces of UI and compose them into whole flexible patterns. In our latest article, we show how to use it to create swappable site sections and integrate it all in a theme.https://t.co/ZRocH8oJSp
— Advanced Custom Fields (@wp_acf) January 24, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.