You are right. It doesn't like the multiple tag fields. We will have to get a little creative to get around the problem. The first hook prevents the tags from being inserted into the post tags. The second hook inserts them into the custom taxonomies using the wp function you found. Let me know how it goes
add_filter("gform_post_data", "empty_tags", 10, 2);
function empty_tags($post_data, $form){
//replace 4 with your actual form id
if($form["id"] !=4)
return;
$post_data["tags_input"] = null;
return $post_data;
}
add_filter("gform_post_submission", "insert_custom_taxonomies", 10, 2);
function insert_custom_taxonomies($entry, $form){
//REPLACE 4 with your actual form id
if($form["id"] !=4)
return;
//getting post
$post_id = $entry["post_id"];
//REPLACE 2 with your actual field id and "post_tag" with your custom taxonomy
wp_set_object_terms($post_id, explode(",", $entry[2]), "post_tag");
//REPLACE 3 with your actual field id and "activities" with your second taxonomy
wp_set_object_terms($post_id, explode(",", $entry[3]), "activities");
}
Posted 14 years ago on Wednesday April 21, 2010 |
Permalink