Last active
June 13, 2022 19:43
-
-
Save spivurno/b5c7af4635b781c5bdf9 to your computer and use it in GitHub Desktop.
Gravity Wiz // Gravity Forms // Content Template for Post Excerpt Field
This file contains 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 | |
/** | |
* Gravity Wiz // Gravity Forms // Content Template for Post Excerpt Field | |
* | |
* Gravity Forms does not currently offer a "Content Template" option for the | |
* Exceprt field. This is a simple snippet that allows you to create | |
*/ | |
// update "433" to the ID of your form | |
add_filter( 'gform_post_data_433', 'gw_post_excerpt_content_template_433', 10, 3 ); | |
function gw_post_excerpt_content_template_433( $post_data, $form, $entry ) { | |
// modify this to include whatever merge tags and words you'd like included in the excerpt | |
$excerpt_template = '{Name (First):1.3} {Name (Last):1.6} tells a riveting tale about {Subject:3}.'; | |
$post_data['post_excerpt'] = GFCommon::replace_variables( $excerpt_template, $form, $entry ); | |
return $post_data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👉 This Gist has been migrated to the Gravity Wiz Snippet Library:
https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-dynamic-post-excerpt.php