Created
March 13, 2013 14:47
-
-
Save eugenoprea/5152825 to your computer and use it in GitHub Desktop.
Gravity Forms - Populate Name Field - Setting Field Default Value Directly - Part 2.
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
// Adds a filter to form id 7. Replace 7 with your actual form id | |
add_filter('gform_pre_render_7', 'eo_form_pre_render'); | |
function eo_form_pre_render($form) | |
{ | |
// if no user is logged-in, do nothing | |
if ( !is_user_logged_in() ) | |
return $form; | |
foreach ($form['fields'] as &$field) | |
{ | |
// replace 2 with the actual ID of your Name field | |
if ( 2 == $field['id'] ) | |
{ | |
eo_populate_name_field($field, array( | |
'first' => eo_get_usermeta('first_name'), | |
'last' => eo_get_usermeta('last_name'), | |
)); | |
break; | |
} | |
} | |
return $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment