Hey there,
I have the below snippet to create a custom merge tag via the gform_replace_merge_tags PHP filter. This is working great and I have successfully used it inside form notifications, which was the intended purpose.
However, one thing I noticed is that the merge tag isn’t being replaced inside the saved entry. Ideally, I’d be able to see the entry exactly how the data was sent in the notification email (in the same way the default merge tags are replaced inside the entry data).
Is this a bug or is there another part I need for this to work like this?
Any help is greatly appreciated!
My code:
add_filter( 'gform_replace_merge_tags', 'replace_reference_number', 10, 7 );
function replace_reference_number( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) {
$custom_merge_tag = '{cstm_reference_number}';
if ( strpos( $text, $custom_merge_tag ) === false ) {
return $text;
}
$reference_number = 'REF-' . str_pad($entry['id'], 6, '0', STR_PAD_LEFT);
return str_replace( $custom_merge_tag, $reference_number, $text );
}
