I have modified the following code snippet from an iThemes Training class on pre-populating gravity forms:
// Prefill with User Data
function populate_usermeta($meta_key){
global $current_user;
return $current_user->__get($meta_key);
}
add_filter('gform_field_value_userfirstname',
create_function("", '$value =
populate_usermeta('user_firstname'); return $value;' ));
add_filter('gform_field_value_userlastname',
create_function("", '$value =
populate_usermeta('user_lastname'); return $value;' ));
add_filter('gform_field_value_useremail',
create_function("", '$value = populate_usermeta('user_email');return $value;' ));
The above code snippet pre-populates data from the current logged in user (user_firstname, user_lastname and user_email), however when I modify the necessary fields to pull data from POD of extended user, I get no values returned. The above snippet works perfect for First Name, Last name and email on a new form (created to just test code)
// Prefill with User Data
function populate_usermeta($meta_key){
global $current_user;
return $current_user->__get($meta_key);
}
add_filter('gform_field_value_deptname',
create_function(" ", '$value = populate_usermeta('departmentname'); return $value;' ));
add_filter('gform_field_value_deptid',
create_function(" ", '$value = populate_usermeta('departmentid'); return $value;' ));
add_filter('gform_field_value_billing',
create_function(" ", '$value = populate_usermeta('billingsite');return $value;' ));
My POD is an extension of User and only contains the three fields above and my GF form is set to accept the values: deptname, deptid, billing).
Basically, I have custom fields that are added to user to show Department Name, Departing ID and Billing site, when the user logs in to submit an incident via GF, we want their department name and ID to be pre-populated to save the department from having to type that information on every incident.
Hope this information help, and feel free to inquire with any more details needed.