Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save blueprintmrk/c1a9577872d64bd2bad1 to your computer and use it in GitHub Desktop.
Save blueprintmrk/c1a9577872d64bd2bad1 to your computer and use it in GitHub Desktop.
Use DateTime for Gravity Forms Salesforce Web-to-Lead Addon
<?php
/**
* 1. Tell the plugin to use DateTime instead of Date for the "MyPrefix__Date_and_Time__c" field
*
* @param string $boolean Whether to use DateTime instead of Date (default: false)
* @param string $key The Field Name (or API Name if a custom field) used in Salesforce
* @param array $additional_info Associative array with form, entry, field, feed data
*/
function modify_gf_salesforce_use_datetime( $boolean = false, $key = '', $additional_info = array() ) {
// Use your own Field Name or API Name below instead of the "MyPrefix__Date_and_Time__c"
// If it matches, DateTime will be used
if( $key === 'MyPrefix__Date_and_Time__c') {
return true;
}
return $boolean; // Otherwise, Date will be used by default
}
add_filter('gf_salesforce_use_datetime', 'modify_gf_salesforce_use_datetime', 10, 3 );
/**
* 2. Change the date format (optional)
*
* If the date format isn't working for DateTime, you can modify it here.
* Use the format shown here for your country:
* @link https://help.salesforce.com/apex/HTViewHelpDoc?id=admin_supported_locales.htm
*/
function modify_gf_salesforce_datetime_format( $format ='Y-m-d H:i:s' ) {
/**
* Use a different format, using the Date Time Formats shown here:
* @link http://codex.wordpress.org/Formatting_Date_and_Time
*/
return 'c';
}
add_filter('gravityforms/salesforce/datetime_format', 'modify_gf_salesforce_datetime_format');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment