I am trying to run a function on post update by checking if an ACF is equal to something.
I'm checking if the ACF value is equal to new or closed.
when i change it from value new to closed and save it doesn't run but if i save the post again when the post is at closed it does run.
function check_values($post_ID){
if(get_field('status', $post_ID ) == "closed") {
sendSMS();
}
}
add_action( 'post_updated', 'check_values', 10, 3 ); //don't forget the last argument to allow all three arguments of the function
Is there something I'm missing about this? I want to avoid saving each post twice.
Thank you
I am trying to run a function on post update by checking if an ACF is equal to something.
I'm checking if the ACF value is equal to new or closed.
when i change it from value new to closed and save it doesn't run but if i save the post again when the post is at closed it does run.
function check_values($post_ID){
if(get_field('status', $post_ID ) == "closed") {
sendSMS();
}
}
add_action( 'post_updated', 'check_values', 10, 3 ); //don't forget the last argument to allow all three arguments of the function
Is there something I'm missing about this? I want to avoid saving each post twice.
Thank you
Share Improve this question edited Mar 9, 2020 at 6:30 sleepingpanda 566 bronze badges asked Mar 8, 2020 at 13:27 Asaf HadadAsaf Hadad 357 bronze badges1 Answer
Reset to default 1Please try using acf/save_post
action that will hook in after ACF data has been saved.
add_action('acf/save_post', 'check_values');
function check_values($post_id){
if(get_field('status', $post_id ) == "closed") {
sendSMS();
}
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744685755a4587904.html
评论列表(0条)