So I have a form that people register with where they enter their first and last name. Then I have a separate form that they can edit once they're logged in that has different / more data. But it also includes their first and last name field. I need to populate that field with the user's first and last name and (for reasons I'm not going to go into here... just trust me... ) can't use the normal conventions to do so.
Therefore I have this code... which works for another field but I can't get it to work on the first and last name field. I'm thinking one of the parameters is defined wrong, but I can't figure out which one. Help?
//Display User Name #
//form # = the "Personal Profile" form (2)
add_filter("gform_pre_render_2", "personal_info");
function personal_info($form) {
if($form["id"] != 2)
return $form;
global $post;
global $current_user;
$first_name = $current_user->first_name;
$last_name = $current_user->last_name;
foreach($form["fields"] as &$field) {
if ($field["id"] == 1.3) {
$field["defaultValue"] = $first_name;
}
if ($field["id"] == 1.6) {
$field["defaultValue"] = $last_name;
}
}
return $form;
}
The $first_name is grabbing the name. btw.
I can test it with a hardcoded string and it still won't work.