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 in multiple forms

  1. conpark
    Member

    Hi,

    i need an option to use custom taxonomies in multiple forms.
    At the moment i use a hook for adding custom taxonomies instead of tags.

    Unfortunately the hook doesn't work if i use it in more than one form.
    Is there an option to adress a specific form and the id of the tag-field?

    For now, the input appears in two custom taxonomies based on the field id...

    Here is the code:

    <?php
    //Tag to Taxonomy - A fix for gravity forms
    
    function hyp_tag_to_taxonomy( $form ){
         $id = $form['post_id'];
         $raw_tag_list = $form['12'];
         $tag_array = explode(',', $raw_tag_list);
    
         foreach ($tag_array as $tag){
              wp_set_object_terms( $id, $tag, 'collective',true);
         }
    }
    
    add_action( 'gform_post_submission', 'hyp_tag_to_taxonomy' );
    
    ?>
    Posted 11 years ago on Sunday November 7, 2010 | Permalink
  2. To address a specific form, you can use the variable $form["id"] To get the field ID, you can inspect the html of the form and get it from the input name (i.e. <input name='input_10" />)

    Posted 11 years ago on Monday November 8, 2010 | Permalink