You would want to use the gform_post_submission hook which has access to the Entry object. The Entry object all data from a submitted form.
You can use the gform_post_submission 2 different ways.
If you want to apply the code to ALL forms you would use it this way:
<?php
add_action("gform_post_submission", "post_submission", 10, 2);
?>
If you want to apply the code to a SPECIFIC form you would use it this way, this example would target form id 5:
<?php
add_action("gform_post_submission_5", "post_submission", 10, 2);
?>
Here is an example of the gform_post_submission in action, this example uses the gform_post_submission hook to change the post content, adding values from submitted fields, including an image field. It doesn't do what you want it to do, it's purely an example of the gform_post_submission usage:
<?php
add_action("gform_post_submission", "set_post_content", 10, 2);
function set_post_content($entry, $form){
//getting post
$post = get_post($entry["post_id"]);
//changing post content
$post->post_content = "Blender Version:" . $entry[7] . "<br/> <img src='" . $entry[8] . "'> <br/> <br/> " . $entry[13] . " <br/> <img src='" . $entry[5] . "'>";
//updating post
wp_update_post($post);
}
?>
The gform_post_submission hook has access to the Entry object. Here are examples:
$entry["date_created"]; //returns the entry date
$entry["1"]; //returns the value associated with field 1
$entry["2.4"]; //returns the value associated with the street input for the address field 2
So you would use the field id OR keywords for default data associated with the entry. These keywords are:
- id
- date_created
- is_starred
- is_read
- ip
- source_url
- post_id
- FIELD_ID
If this is all greek to you... then hiring a WordPress consultant to do the implementation may not be a bad idea. I would recommend:
Ounce of Talent
http://www.ounceoftalent.com
WebDevStudios
http://www.webdevstudios.com
Posted 13 years ago on Wednesday February 9, 2011 |
Permalink