I almost have it figured out but stuck due to lack of PHP knowledge; basically I need a custom Gravity Forms merge tag to display the "date_created" entry object as this has the date and time of form submission. It should look something like this but this is wrong:
<?php
add_filter('gform_custom_merge_tags', 'custom_merge_tags', 10, 4);
function custom_merge_tags($merge_tags, $form_id, $fields, $element_id) {
if($entry["date_created"]($form_id))
$merge_tags[] = array('label' => 'Date Created', 'tag' => '{date_created}');
return $merge_tags;
}
?>
Any help?
It is a two step process. You first create the merge tag, and then at some point, you have to replace the merge tag with the correct data. I can't see a reason, why you would need the if($entry["date_created"]
line in this part of the code.
Then you'll want to create another function that replaces the merge code.
add_filter('gform_replace_merge_tags', 'replace_gf_date', 10, 7);
function replace_gf_date($text, $form, $entry, $url_encode, $esc_html, $nl2br, $format) {
$custom_merge_tag = '{date_created}';
if(strpos($text, $custom_merge_tag) === false)
return $text;
$gf_date_created = ($entry[date_created"]($formID))
//Not sure of exact syntax above.
$text = str_replace($custom_merge_tag, $gf_date_created, $text);
return $text;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.