Last active
February 17, 2016 01:45
-
-
Save kevinwhoffman/e3ec070973fabd36a2c4 to your computer and use it in GitHub Desktop.
Pre-populate Gravity Form Field Based on Query Parameter
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 | |
/** | |
* Given a URL like http://example.com/?id=1 this function will pre-populate a Gravity Form field called 'fname'. | |
* For more info, see GF docs: https://www.gravityhelp.com/documentation/article/gform_field_value_parameter_name/ | |
*/ | |
add_filter( 'gform_field_value_fname', 'populate_fname' ); | |
function populate_fname() { | |
$id = $_GET['id']; | |
$user = get_user_by( 'id', $id ); | |
return $user->first_name; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment