Sascha,
I understand what you are trying to do now. It will take a little bit more code, but we still can get it done.
1- Setup Form A, and get the IDs for all fields you would like to be "sent" to Form B. You can get the Ids by looking at the html source of the form. The li containing the field will have the field id in it's ID attribute. It is formatted like such: "field_FORMID_FIELDID"
2- Add hidden fields to Form B. One for each field you want to send to the user.
Setup this hidden fields to "allow field to be populated dynamically" and give it a parameter name (i.e. shoesize)
3- Add the following code to your functions.php (this will only populate one field. to populate multiple fields, you will need to add this multiple times with the proper values replaced)
add_filter("gform_field_value_shoesize", "populate_shoesize");
function populate_shoesize(){
global $post;
global $wpdb;
$table_name = $wpdb->prefix . "rg_lead";
//getting the entry id that generated this post
$entry_id = $wpdb->get_var($wpdb->prepare("select id from $table_name where post_id=%d", $post->ID));
$shoesize = "";
if(!empty($entry_id)){
//loading the entry with all fields
$entry = RGFormsModel::get_lead($entry_id);
//getting one of the entry's fields (by ID - The ID can be found by looking at the form's html source. The input will be formated as "input_ID").
$shoesize = $entry[1]; //The 1 here is the id of the field to be returned. You can get it by looking at the html source of the form.
}
return $shoesize;
}
In the following line, "shoesize" should be replaced with the parameter name you gave your hidden field on Form B.
add_filter("gform_field_value_shoesize", "populate_shoesize");
AND in the following line, replace 1 with your field id from Form A
$shoesize = $entry[1];
Now you can setup your notification using this hidden fields and the values will be sent to the user.
NOTE: This is method performs a couple of queries for each field you have to populate, so it may not be a great idea to use this method if you are loading a bunch of fields. You probably won't notice any performance issues if you have less than 10 fields, I don't think.
Posted 15 years ago on Wednesday October 21, 2009 |
Permalink