Support

Account

Home Forums Feature Requests Option to trim custom field Reply To: Option to trim custom field

  • Who wants same feature, there is solution:

    put this to functions.php

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