I believe with this snippet, one shall be able to populate a field in wordpress gravity forms:
add_filter( "gform_field_value_products", "mu_populate_products" );
function mu_populate_products() {
global $currUserEntry;
if($currUserEntry){
$e = rgar( $currUserEntry, '37' );
alertUser(maybe_unserialize($e));
return $e;
}
}
I can assure you that $e
contains exactly the data which has been sent after validation of the form to the database, and the 37
and products
are what they should be, I think the problem is that this products field is a list with two columns and the first column is concerted to <select>
by this snippet:
add_filter( 'gform_column_input_30_37_1', 'set_column', 10, 5 );
function set_column( $input_info, $field, $column, $value, $form_id ) {
return array( 'type' => 'select', 'choices' => 'choice 1, choice 2' );
}
any help would be appreciated
Well after a while here is the answer, for googlers perhaps,
function mu_populate_products() {
global $currUserEntry;
if($currUserEntry){
$e = rgar( $currUserEntry, '37' );
return maybe_unserialize($e);
}
}
all the point is that the function must return a deserialized object, while the rgar
which returns the field value from db is serialized, so using maybe_unserialize
was the key.
also bear in mind that this works since Gravity Forms 1.9.10.8
for more info: https://www.gravityhelp.com/documentation/article/gform_field_value_parameter_name/#3-list-field