Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Dynamically populate Gravity Forms fields with WordPress user info for logged in users using get_currentuserinfo().
//* Using the Gravity Forms editor, be sure to check "Allow field to be populated dynamically under Advanced Options
//* You will need to set the Field Parameter Name value to work with the filter as follows: gform_field_value_$parameter_name
//* Dynamically populate first name for logged in users
add_filter('gform_field_value_first_name', 'populate_first_name');
function populate_first_name($value){
global $current_user;
return $current_user->user_firstname;
//* Dynamically populate last name for logged in users
add_filter('gform_field_value_last_name', 'populate_last_name');
function populate_last_name($value){
global $current_user;
return $current_user->user_lastname;
//* Dynamically populate email for logged in users
add_filter('gform_field_value_email', 'populate_email');
function populate_email($value){
global $current_user;
return $current_user->user_email;
//* This method can also be used for custom user fields, e.g...
//* Dynamically populate phone for logged in users
add_filter('gform_field_value_phone', 'populate_phone');
function populate_phone($value){
global $current_user;
return $current_user->phone;

This comment has been minimized.

Copy link

@maristhek maristhek commented May 9, 2018

Please clarify parameter name usage. None of the variations of "gform_field_value_$parameter_name" work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment