Turns out through priority help from Alex I was able to get a work around. Here is my final code to create a new merge tag that pulls the entry notes and include them in email:
[php]
add_filter('gform_custom_merge_tags', 'custom_merge_tags', 10, 4);
function custom_merge_tags($merge_tags, $form_id, $fields, $element_id) {
$merge_tags[] = array('label' => 'Entry Notes', 'tag' => '{entry_notes}');
return $merge_tags;
}
add_filter( 'gform_replace_merge_tags', 'replace_entry_notes', 10, 7 );
function replace_entry_notes( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) {
$custom_merge_tag = '{entry_notes}';
if ( strpos( $text, $custom_merge_tag ) === false ) {
return $text;
}
$notes = RGFormsModel::get_lead_notes( $entry['id'] );
$entry_notes = '';
if ( $notes ) {
$entry_notes .= "<br><br><strong>Additional Notes</strong><br>";
foreach ( $notes as $note ) {
$date = new DateTime( $note->date_created, new DateTimeZone( 'Europe/London' ) );
date_default_timezone_set( 'America/New_York' );
$entry_notes .= "<em>" . $note->user_name . ' - ' . date( 'F j, Y, g:i a', $date->format( 'U' ) ) . "</em><br>";
$entry_notes .= $note->value . "<br><br>";
}
}
$entry_notes = str_replace( $custom_merge_tag, $entry_notes, $text );
return $entry_notes;
}
Posted 11 years ago on Wednesday March 6, 2013 |
Permalink