Created
March 13, 2013 14:43
-
-
Save eugenoprea/5152780 to your computer and use it in GitHub Desktop.
Gravity Forms - Populate Name Field - Using Dynamic Population Parameters
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
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