The code (see link, posting code here gave errors) should send out an email every time I change the STATUS field and then safe/update the post. But it’s not working and I do know why:
The field updates are always saved AFTER the post is saved so it always sends out the PREVIOUS field values (its like I’m always 1 step behind).
How can I let the POST UPDATE come LAST so that the then triggered email-action will have the latest field values included?
https://stackoverflow.com/questions/62221356/wordpress-post-update-after-acf-field-updates
ACF will not update the values before the post is saved.
You can:
— use the acf/save_post hook instead of the WP hook
— you can get the new values from $_POST[‘acf’] instead of using get_field()
both are explained here https://www.advancedcustomfields.com/resources/acf-save_post/
Somehow I can’t post my code here so I had two update my question on STACK.
No errors come up but also NO emails are being send… Can you check the UPDATES code and give me some advise? I know I’m sooooo close here…
CODE:
https://stackoverflow.com/questions/62221356/wordpress-post-update-after-acf-field-updates
when using $_POST[‘acf’] you need to use field keys instead of field names
$_POST['acf']['field_XXXXXXX']