Skip to content

Instantly share code, notes, and snippets.

@blueprintmrk
Forked from eugenoprea/functions.php
Last active August 29, 2015 14:13
Show Gist options
  • Save blueprintmrk/bf0bd46f68dbf0d14964 to your computer and use it in GitHub Desktop.
Save blueprintmrk/bf0bd46f68dbf0d14964 to your computer and use it in GitHub Desktop.
// 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