PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Custom Taxonomies for Multiple forms

  1. Hi Support

    I am trying to get CPT Taxonomies working using Gravity Forms.
    The first form with ID 1 works, however I cannot get the 2nd form Taxonomies to work using the same method could someone possibility suggest what I have done incorrect?

    ('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"] !=1){$post_data["tags_input"] = null;}

    if($form["id"] !=2){$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"] !=1)
    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[7]), "directory-province");

    //REPLACE 3 with your actual field id and "activities" with your second taxonomy
    wp_set_object_terms($post_id, explode(",", $entry[8]), "directory-type");

    //REPLACE 4 with your actual form id
    if($form["id"] !=2)
    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[4]), "classified-province");

    //REPLACE 3 with your actual field id and "activities" with your second taxonomy
    wp_set_object_terms($post_id, explode(",", $entry[5]), "classified-type");

    }
    ')

    Thanks in advance

    Posted 13 years ago on Thursday January 13, 2011 | Permalink
  2. Hi Justin,

    Give this a go: http://pastie.org/1457195

    Posted 13 years ago on Thursday January 13, 2011 | Permalink