Support

Account

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.