Forked from zackkatz/gf-salesforce-web-to-lead-datetime.php
Created
November 3, 2015 00:46
-
-
Save blueprintmrk/c1a9577872d64bd2bad1 to your computer and use it in GitHub Desktop.
Use DateTime for Gravity Forms Salesforce Web-to-Lead Addon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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