Figured it out. The publish-hook is to early for ACF, so none of the newly published fields are ready yet. I changed it up to this:
add_action( 'save_post', 'save_jobb', 100, 3 );
..also cranking up the priority to 100, to make sure that all other save jobs are done first.
Furthermore I added a check for post type early in the new function, since the new one takes on all posting in general:
$post_type = get_post_type($post_id); if ( "jobb" != $post_type ) return;
Lastly, to prevent emails from being sent every time I edit a post belonging to a customer, I also added a small, new ACF field named
mailsendt – to just hold the value 0 or 1 depending on whether a mail already has been sent or not.
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!
© 2022 Advanced Custom Fields.