Hi!
I've searched the forums but cant find anything about this particular thing so here goes..
I got a pretty complex form which is supposed to pull in data from the currently logged in user and put it into some fields..
I've tried both this solution :
http://www.gravityhelp.com/documentation/page/Gform_field_value_$parameter_name
and using the gform_pre_render_1 hook in order to do this and they both work fine.. The users info is automatically put into the values of the fields..
however when I then submit the form these values are not passed on to the entry or the email confirmation.. they appear as empty fields.. regardless of which of the two ways to prepopulate Im using!
I'm really friggin frustrated so now I'm asking for help.. could this be a bug or?
Here's how the version with the pre_render hook looks like (I put the content into the $field['content'] parameter as well just to try, didnt change anything):
$user_id = get_current_user_id();
$user_fields = get_fields('user_'.$user_id);
if(strpos($field['cssClass'], 'disabled') !== false){
if($user_fields){
foreach($user_fields as $fieldname => $fieldvalue){
$fieldname = str_replace('user_', 'order_', $fieldname);
$fieldclass = explode(' ', $field['cssClass']);
if($fieldname == $fieldclass[0]){
$field['defaultValue'] = $fieldvalue;
$field['content'] = $fieldvalue;
}
}
}
}
And heres how the other version look like (with just a sample filter):
add_filter('gform_field_value_user_business', create_function("", '$value = populate_usermeta(\'user_business\'); return $value;' ));
function populate_usermeta($meta_key){
$user_id = get_current_user_id();
$user_fields = get_fields('user_'.$user_id);
//return $current_user->__get($meta_key);
if($user_fields){
foreach($user_fields as $fieldname => $fieldvalue){
if($meta_key == $fieldname){
return $fieldvalue;
}
}
}
}
I'm using Advanced custom fields for creating the user meta but that doesnt really matter since they're just values and that part I know works fine since the output is actually visible on the form frontend.
And yes, I've set the fields to dynamic population and checked the parameter for that. :)