Support

Account

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.