Skip to content

Instantly share code, notes, and snippets.

@eugenoprea
Created March 13, 2013 14:43
Show Gist options
  • Save eugenoprea/5152780 to your computer and use it in GitHub Desktop.
Save eugenoprea/5152780 to your computer and use it in GitHub Desktop.
Gravity Forms - Populate Name Field - Using Dynamic Population Parameters
add_filter('gform_field_value_first_name', 'eo_populate_name');
add_filter('gform_field_value_last_name', 'eo_populate_name');
function eo_populate_name($value)
{
// extract the parameter name from the current filter name
$param = str_replace('gform_field_value_', '', current_filter());
// we are interested only in the first_name and last_name parameters
if ( !in_array($param, array('first_name', 'last_name')) )
return $value;
// incidentally, the user meta keys for the first and last name are
// 'first_name' and 'last_name', the same as the parameter names
$value = eo_get_usermeta($param);
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment