Skip to content

Instantly share code, notes, and snippets.

@uamv
Last active May 26, 2022 01:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save uamv/10c9d435600d69af7d2b3ef03957079d to your computer and use it in GitHub Desktop.
Save uamv/10c9d435600d69af7d2b3ef03957079d to your computer and use it in GitHub Desktop.
Add custom merge tags to Gravity Forms
<?php
add_filter( 'gform_replace_merge_tags', 'typewheel_custom_merge_tags', 10, 7 );
function typewheel_custom_merge_tags( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) {
$custom_merge_tags = array(
'{date_ymd}' => date( 'Y.m-M.d', strtotime( $entry['date_created'] ) ),
'{timestamp}' => time(),
'{site_url}' => get_site_url(),
'{site_name}' => get_bloginfo( 'name' )
);
return str_replace( array_keys( $custom_merge_tags ), array_values( $custom_merge_tags ), $text);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment