Reputation: 29
I am hoping someone could please assist with the below snippet, I need for one of my fields values to be deleted when a different select field is changed to complete.
add_action('acf/save_post', 'my_acf_save_post');
function my_acf_save_post($post_id){
$status = get_field('status');
if ('complete', $status){
delete_field('project_address');
}
}
Upvotes: 0
Views: 703
Reputation: 166
You need to pass the "post_id" to select the value and delete the value. Logic it true, I think.
add_action('acf/save_post', 'my_acf_save_post');
function my_acf_save_post( $post_id ){
$status = get_field( 'status', $post_id );
if ( 'complete' === $status ){
delete_field( 'project_address', $post_id );
}
}
Hope it help.
Upvotes: 1