Convert ACF Date Into Gravity Forms Date

This snippet will format the value from a ACF Date field that is retrieved from the database and convert it into a Gravity Forms format Date field.

Instructions

  1. Download and install as a plugin.
  2. Go to the field settings for the Gravity Forms Date field you are populating from the ACF Date field.
  3. Add “gppa-format-acf-date” to the “Custom CSS Class” setting (on the Appearance tab).
Read the Walkthrough

Code

Filename: gppa-acf-date-formatter.php

<?php
/**
 * Gravity Perks // Populate Anything // Convert ACF Date Into Gravity Forms Date
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 *
 * Instructions:
 *
 * 1. Download and install as a plugin.
 * 2. Go to the field settings for the Gravity Forms Date field you are populating from the ACF Date field.
 * 3. Add "gppa-format-acf-date" to the "Custom CSS Class" setting (on the Appearance tab).
 *
 * Plugin Name:  GPPA ACF Date to GF Date
 * Plugin URI:   http:///gravitywiz.com.com/documentation/gravity-forms-populate-anything/
 * Description:  This snippet will format the value from a ACF Date field that is retrieved from the database and convert it into a Gravity Forms format Date field.
 * Author:       Gravity Wiz
 * Version:      0.1
 * Author URI:   https://gravitywiz.com
 */
add_filter( 'gppa_process_template_value', function( $template_value, $field, $template_name, $populate, $object, $object_type, $objects ) {

	if ( strpos( $field->cssClass, 'gppa-format-acf-date' ) === false ) {
		return $template_value;
	}

	return wp_date( 'd/m/Y', strtotime( $template_value ) );
}, 10, 7 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.