Last active
March 19, 2020 16:37
-
-
Save leepettijohn/33621067d6ba649a7b9baeb55cbbb3bb to your computer and use it in GitHub Desktop.
Gravity Forms - dynamically populate fields
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 | |
/* *** replace "your_parameter" with the parameter in the advanced tab | |
https://docs.gravityforms.com/using-dynamic-population/ */ | |
add_filter( 'gform_field_value_your_parameter', 'my_custom_population_function' ); | |
function my_custom_population_function( $value ) { | |
return 'boom!'; | |
} | |
/*Use this for a real estate form */ | |
add_filter( 'gform_field_value_property_name', 'wap_populate_post_title' ); | |
function wap_populate_post_title( $value ) { | |
// bail if we aren't on a single listing CPT | |
if ( ! is_singular( 'listing' ) ) { | |
return; | |
} | |
// fetch the post title | |
$title = get_the_title(); | |
// return value escaped | |
return esc_html( $title ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment