Created
December 20, 2021 11:40
-
-
Save yuliyang/ac8d4e1f3af3575a68b4cbba6e1b2d06 to your computer and use it in GitHub Desktop.
[Gravity Forms] Custom Merge Tags
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 | |
add_filter('gform_custom_merge_tags', 'ching_custom_merge_tags', 10, 4); | |
function ching_custom_merge_tags( $merge_tags, $form_id, $fields, $element_id ) { | |
$merge_tags[] = array('label' => 'Open Present', 'tag' => '{open_present}'); | |
return $merge_tags; | |
} | |
add_filter('gform_replace_merge_tags', 'ching_replace_merge_tags', 10, 3); | |
function ching_replace_merge_tags( $text, $form, $entry ) { | |
if ( strpos( $text, '{open_present}' ) ) { | |
$text = str_replace( '{open_present}', 'Here it is!', $text ); | |
} | |
return $text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment