Support

Account

Forum Replies Created

  • 1. I am using latest ACF PRO version.
    2. Yes

    If I change the Field name to “latin-name-branje” (Field label “Latin name branje”) then saving works but previously inserted fields which were under “latin_name_branje” ofcourse won’t show.

    Ah nvm, I am fiddling with this too long, for few hours. I have now placed again my code for manual meta box and this works so I will just stick to it…

    Thank you neverthless

  • Hm it didn’t matter if I called get_post_meta before, the number of queries was the same. But I managed to solved it like you mentioned, by using variables from get_post_meta array.

  • Sorry for replying to a 2 year old post. I agree that trimming fields should be included in the plugin. But the code posted by Radovan didn’t worked for me, since I also have checkboxes (in the end the ACF values aren’t strings but an array, and former code fails).

    Here is a slightly improved code for anyone stumbling on this page

    function trim_acf_fields( $post_id )
    {
      // load from post
      if( isset($_POST['fields']) ) {
        foreach($_POST['fields'] as $key => $value) {
          if(!is_array($value))
            $_POST['fields'][$key] = trim($value);
        }
      }
    }
    // run before ACF saves the $_POST['fields'] data
    add_action('acf/save_post', 'trim_acf_fields', 1);
Viewing 3 posts - 1 through 3 (of 3 total)