Skip to content

Instantly share code, notes, and snippets.

@kevinwhoffman
Last active February 17, 2016 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinwhoffman/e3ec070973fabd36a2c4 to your computer and use it in GitHub Desktop.
Save kevinwhoffman/e3ec070973fabd36a2c4 to your computer and use it in GitHub Desktop.
Pre-populate Gravity Form Field Based on Query Parameter
<?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