Home Forums Backend Issues (wp-admin) update_value hook not working when saving post Reply To: update_value hook not working when saving post

  • More than likely you are updating the field and then ACF is overwriting it with the submitted value. acf/update_field is called when the field is being updated. So the other field has probably not been updated yet when you update it.

    You need to use an acf/save_post filter and do all the work after ACF has finished saving the post

    or you need to update the $_POST[‘acf’][$field_key] value of the field you want to change.

    function save_post_functions( $post_id ) {
      $my_post = array();
      $my_post['ID'] = $post_id;
      if ( get_post_type( ) == 'artists') {
    	$artist_name = get_field('artist_name');
    	$artist_sort = get_field('artist_sort');
    	$name_sort = name_sort($artist_name);
    	if (substr_count($name_sort,'%')>0) { $name_sort = $artist_name; }
            if (isset($_POST['acf']['field_XYZ123'])) { // replace with your field key
              $_POST['acf']['field_XYZ123'] = $name_sort;
            } else {
    add_action('acf/save_post', 'save_post_functions', 20);