Support

Account

Home Forums Backend Issues (wp-admin) Getting Gravity Forms date field into ACF date field?

Solving

Getting Gravity Forms date field into ACF date field?

  • Hi – I’m using gravity forms to set up a front-end form that creates a draft of a custom post type – I’ve got most everything working as intended with one exception – I’m not able to figure out how to pass a date collected with a Gravity Forms date field into an ACF date field. I can pass a GF date field into an ACF text field, but I need my admin users to be able to edit that date once it’s in place – is there a way to do this?

    Thanks in advance for any help!

  • @elemenopy: Did you ever figure anything out on this? Looking in my own database it’s most likely the format that the date is saved in. I’m seeing an example that was created in the admin page ACF form that is saved in the format (YYYYMMDD) and when the post is created through gravity forms date field, it’s saved into the wp_postmeta table in the format (MM/DD/YYYY).

  • Is there any update on this item? Just encountered it myself.

    Edit: Nevermind! Found a solution:

    function acf_smart_dates($field) {
      if ($field['value']) {
        $field['value'] = date('Ymd',strtotime($field['value']));
      }
      return $field;
    }
    add_filter('acf/prepare_field/type=date_picker','acf_smart_dates');

    From: http://blog.room34.com/archives/5597

  • Just as an update to this I had to alter the function to make this work, see the below:

    function acf_smart_dates($field) {
      if ($field['value']) {
      	$date = DateTime::createFromFormat('d/m/Y', $field['value']);	
        $field['value'] = date_format($date, 'Ymd');
      }
      return $field;
    }
    add_filter('acf/prepare_field/type=date_picker','acf_smart_dates');
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Getting Gravity Forms date field into ACF date field?’ is closed to new replies.