Home Forums Bug Reports update_field inside acf/update_value/name filter not working


update_field inside acf/update_value/name filter not working

  • i am trying to update two custom field within the update_value filter but its not working. here is the code.

    function my_acf_update_value( $value, $post_id, $field  )
      // post data to update
      $post_data = array(
          'ID'           => $post_id,
          'post_name' => $value,
          'post_date' => $value
      // Update the post into the database
      wp_update_post( $post_data );
      // updating the other custom fields
      //update_post_meta($post_id, '_fs-backlink', $value);
      update_field('_fs-backlink', $value, $post_id);
      update_field('_fs-audio', str_replace('-', "", $value), $post_id);
      return $value;
    add_filter('acf/update_value/name=_fs-date', 'my_acf_update_value', 10, 3);

    first i have updated the post its working fine (wp_update_post). but then two other custom fields to be updated they are not getting updated. not even the update_post_meta function working here.

    i have also tried with the field key but no luck. also tried to run the custom query instead of update_field still no luck.

  • Hi @eafarooqi,

    From your code, you are hooking into the update_value function for a specific field and thus you cannot use the update_field() function within this function.

    I would suggest you hook into the filter for every field or possibly use the update field() function for the other fields on their own.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘update_field inside acf/update_value/name filter not working’ is closed to new replies.