Hello,
I’m using a hook inside functions.php on “publish_post”.
Inside the functions that is triggered i try to use get_field but i’m getting “false” as a result.
Is there something i can do to get the value?
Thank you!
Hi, you could pass the post id as a param to your function and then use get_field with the post id
I have already done that…not working…
Hi, I was doing it like this, (I was using the update_field functions but with get_field it should work ass well)
// run AFTER ACF saves the $_POST['fields'] data
add_action('acf/save_post', 'my_acf_save_post', 20);
function my_acf_save_post( $post_id ){
$var = get_field('field_name', $post_id );
}
that should get you the saved values after they are saved, if you want to modify them before they are saved you should use :
// run before ACF saves the $_POST['fields'] data
add_action('acf/save_post', 'my_acf_save_post', 1);
and then follow the doc here:
http://www.advancedcustomfields.com/resources/actions/acfsave_post/