spivurno
9/30/2016 - 4:01 AM

Gravity Wiz // Gravity Forms // Notes Merge Tag

Gravity Wiz // Gravity Forms // Notes Merge Tag

<?php
/**
 * Gravity Wiz // Gravity Forms // Notes Merge Tag
 * Include entry notes in notifications (and other places merge tags are supported post-entry-creation).
 * http://gravitywiz.com/
 */
add_filter( 'gform_replace_merge_tags', function( $text, $form, $entry ) {

	if( strpos( $text, '{notes}' ) === false ) {
		return $text;
	}

	$notes        = GFFormsModel::get_lead_notes( $entry['id'] );
	$notes_markup = '';

	if ( ! empty( $notes ) ) {
		ob_start();
		GFEntryDetail::notes_grid( $notes, false );
		$notes_markup = ob_get_clean();
	}

	return str_replace( '{notes}', $notes_markup, $text );
}, 10, 3 );