Home › Forums › General Issues › How can I update one acf value with another on save? › Reply To: How can I update one acf value with another on save?
I have tried with the following instead:
// Testing to save/update field value using another field value
function my_acf_save_post( $post_id ) {
// Get newly saved values.
$values = get_fields( $post_id );
$location = get_field('location', $post_id);
$street_name = get_field('street_name', $post_id);
if ( ! get_post_type == 'realestate') {
// Stop right away
return;
} else {
// Check the new value of a specific field.
if ($location['street_name']) {
$street_name = $location['street_name'];
}
}
}
add_action('acf/save_post', 'my_acf_save_post');
Of course this is not doing anything because I don’t understand the documentation properly. Please help.
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.