<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Code to specify that a tag entered in a form should go to a custom taxonomy</title>
		<link>https://legacy.forums.gravityhelp.com/topic/code-to-specify-that-a-tag-entered-in-a-form-should-go-to-a-custom-taxonomy</link>
		<description>Gravity Support Forums Topic: Code to specify that a tag entered in a form should go to a custom taxonomy</description>
		<language>en-US</language>
		<pubDate>Mon, 20 Apr 2026 08:08:55 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/code-to-specify-that-a-tag-entered-in-a-form-should-go-to-a-custom-taxonomy" rel="self" type="application/rss+xml" />

		<item>
			<title>David Smith on "Code to specify that a tag entered in a form should go to a custom taxonomy"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/code-to-specify-that-a-tag-entered-in-a-form-should-go-to-a-custom-taxonomy#post-36352</link>
			<pubDate>Tue, 27 Sep 2011 12:33:40 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">36352@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Richard,&#60;/p&#62;
&#60;p&#62;Are you using Gravity Form Post Tag fields for these field types? If so, try using just a single line text input.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>RichardBest on "Code to specify that a tag entered in a form should go to a custom taxonomy"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/code-to-specify-that-a-tag-entered-in-a-form-should-go-to-a-custom-taxonomy#post-36294</link>
			<pubDate>Mon, 26 Sep 2011 23:58:22 +0000</pubDate>
			<dc:creator>RichardBest</dc:creator>
			<guid isPermaLink="false">36294@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;So here's another update. There was an error of some sort in the code above. The code below ALMOST works but not 100% as intended. It DOES now assign tags to designated taxonomies but it ALSO assigns them the WP default tag taxonomy. &#60;/p&#62;
&#60;p&#62;If I could get the code to assign tags in the specified fields ONLY to the designated taxonomies, it would be working perfectly. (The WP default tag taxonomy would still need to work for other tag fields not referred to in the code.)&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_action(&#38;#39;gform_post_submission&#38;#39;, &#38;#39;hyp_tag_to_taxonomy&#38;#39;, 10, 2);
function hyp_tag_to_taxonomy($entry, $form){

    $post_id = $entry[&#38;#39;post_id&#38;#39;];
    $taxonomy = &#38;#39;&#38;#39;;

    foreach($form[&#38;#39;fields&#38;#39;] as $field) {
        switch($form[&#38;#39;id&#38;#39;]) {
        case 1: // enter your form ID here
           switch($field[&#38;#39;id&#38;#39;]) {
           case 12: // update to a field ID which contains a list of tags
              $taxonomy = &#38;#39;your-tax-name&#38;#39;;
              $tag_string = $entry[12];
              break;
           case 14: // update to a field ID which contains a list of tags
              $taxonomy = &#38;#39;different-tax-name&#38;#39;;
              $tag_string = $entry[14];
              break;
           }
           break;
        case 2: // enter your form ID here
           switch($field[&#38;#39;id&#38;#39;]) {
           case 13: // update to a field ID which contains a list of tags
              $taxonomy = &#38;#39;your-tax-name&#38;#39;;
              $tag_string = $entry[12];
              break;
           case 15: // update to a field ID which contains a list of tags
              $taxonomy = &#38;#39;different-tax-name&#38;#39;;
              $tag_string = $entry[14];
              break;
           }
           break;
        }

        $tags = array_map(&#38;#39;trim&#38;#39;, explode(&#38;#39;,&#38;#39;, $tag_string));

        if(!$post_id &#124;&#124; empty($tags))
            return;

        foreach($tags as $tag)
            wp_set_object_terms($post_id, $tag, $taxonomy, true);

    }

}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>RichardBest on "Code to specify that a tag entered in a form should go to a custom taxonomy"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/code-to-specify-that-a-tag-entered-in-a-form-should-go-to-a-custom-taxonomy#post-36288</link>
			<pubDate>Mon, 26 Sep 2011 22:11:07 +0000</pubDate>
			<dc:creator>RichardBest</dc:creator>
			<guid isPermaLink="false">36288@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi All - In case it helps, I had a developer look at combining the two bits of code referred to above. He produced the following but it didn't work:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;// Adding ability to direct tags to specified taxonomies across different forms

add_action(&#38;#39;gform_post_submission&#38;#39;, &#38;#39;hyp_tag_to_taxonomy&#38;#39;, 10, 2);
function hyp_tag_to_taxonomy($entry, $form){

    $post_id = $entry[&#38;#39;post_id&#38;#39;];
    $taxonomy = &#38;#39;&#38;#39;;

    foreach($form[&#38;#39;fields&#38;#39;] as $field) {
        switch($form[&#38;#39;id&#38;#39;]) {
        case 16: // enter your form ID here
           switch($field[&#38;#39;id&#38;#39;]) {
           case 3: // update to a field ID which contains a list of tags
              $taxonomy = &#38;#39;Projects&#38;#39;;
              $tag_string = $entry[3];
              break;
           case 4: // update to a field ID which contains a list of tags
              $taxonomy = &#38;#39;Status&#38;#39;;
              $tag_string = $entry[4];
              break;
           }
           break;
        case 17: // enter your form ID here
           switch($field[&#38;#39;id&#38;#39;]) {
           case 13: // update to a field ID which contains a list of tags
              $taxonomy = &#38;#39;your-tax-name&#38;#39;;
              $tag_string = $entry[12];
              break;
           case 15: // update to a field ID which contains a list of tags
              $taxonomy = &#38;#39;different-tax-name&#38;#39;;
              $tag_string = $entry[14];
              break;
           }
           break;
        }

        $tags = array_map(&#38;#39;trim&#38;#39;, explode(&#38;#39;,&#38;#39;, $tag_string));

        if(!$post_id &#124;&#124; empty($tags))
            return;

        foreach($tags as $tag)
            wp_set_object_terms($id, $tag, $taxonomy, true);

    }

}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>RichardBest on "Code to specify that a tag entered in a form should go to a custom taxonomy"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/code-to-specify-that-a-tag-entered-in-a-form-should-go-to-a-custom-taxonomy#post-36073</link>
			<pubDate>Fri, 23 Sep 2011 15:42:52 +0000</pubDate>
			<dc:creator>RichardBest</dc:creator>
			<guid isPermaLink="false">36073@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks Carl. No problem. Sorry to hear you're crook David.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Carl Hancock on "Code to specify that a tag entered in a form should go to a custom taxonomy"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/code-to-specify-that-a-tag-entered-in-a-form-should-go-to-a-custom-taxonomy#post-36064</link>
			<pubDate>Fri, 23 Sep 2011 15:20:36 +0000</pubDate>
			<dc:creator>Carl Hancock</dc:creator>
			<guid isPermaLink="false">36064@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;David is out sick today, so you will have to wait until he returns and he can take a look at the code.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>RichardBest on "Code to specify that a tag entered in a form should go to a custom taxonomy"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/code-to-specify-that-a-tag-entered-in-a-form-should-go-to-a-custom-taxonomy#post-36056</link>
			<pubDate>Fri, 23 Sep 2011 15:12:15 +0000</pubDate>
			<dc:creator>RichardBest</dc:creator>
			<guid isPermaLink="false">36056@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi GF team - No problem if you're too busy, but it'd be great for confirmation please as to whether my code attempt above is good or bad (I suspect the latter) before the weekend so I can continue work on the site over the weekend.&#60;/p&#62;
&#60;p&#62;As always, thanks for the super support.&#60;br /&#62;
Richard
&#60;/p&#62;</description>
		</item>
		<item>
			<title>RichardBest on "Code to specify that a tag entered in a form should go to a custom taxonomy"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/code-to-specify-that-a-tag-entered-in-a-form-should-go-to-a-custom-taxonomy#post-35993</link>
			<pubDate>Thu, 22 Sep 2011 18:05:25 +0000</pubDate>
			<dc:creator>RichardBest</dc:creator>
			<guid isPermaLink="false">35993@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi - Would be great if someone could let me know if I have this code right please. I'm keen not to stuff things up... :)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>RichardBest on "Code to specify that a tag entered in a form should go to a custom taxonomy"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/code-to-specify-that-a-tag-entered-in-a-form-should-go-to-a-custom-taxonomy#post-35929</link>
			<pubDate>Wed, 21 Sep 2011 21:45:21 +0000</pubDate>
			<dc:creator>RichardBest</dc:creator>
			<guid isPermaLink="false">35929@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;P.S. If that's right, would the complete code be:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php

add_action(&#38;#39;gform_post_submission&#38;#39;, &#38;#39;hyp_tag_to_taxonomy&#38;#39;, 10, 2);
function hyp_tag_to_taxonomy($entry, $form){

    $post_id = $entry[&#38;#39;post_id&#38;#39;];
    $taxonomy = &#38;#39;&#38;#39;;

switch($form_id) {
case 1: // update to form ID

    switch($field_id) {
    case 5: // update to a field ID which contains a list of tags
            $taxonomy = &#38;#39;your-tax-name&#38;#39;;
            $tag_string = $entry[5];
            break;
    case 6: // update to a field ID which contains a list of tags
            $taxonomy = &#38;#39;different-tax-name&#38;#39;;
            $tag_string = $entry[6];
            break;
    }

case 2: // update to form ID

    switch($field_id) {
    case 7: // update to a field ID which contains a list of tags
            $taxonomy = &#38;#39;your-tax-name&#38;#39;;
            $tag_string = $entry[7];
            break;
    case 8: // update to a field ID which contains a list of tags
            $taxonomy = &#38;#39;different-tax-name&#38;#39;;
            $tag_string = $entry[8];
            break;
    }

$tags = array_map(&#38;#39;trim&#38;#39;, explode(&#38;#39;,&#38;#39;, $tag_string));

        if(!$post_id &#124;&#124; empty($tags))
            return;

        foreach($tags as $tag)
            wp_set_object_terms($id, $tag, $taxonomy, true);

}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Putting the two chunks of code together proves to be more challenging than 1+1 (for me at least). :)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>RichardBest on "Code to specify that a tag entered in a form should go to a custom taxonomy"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/code-to-specify-that-a-tag-entered-in-a-form-should-go-to-a-custom-taxonomy#post-35928</link>
			<pubDate>Wed, 21 Sep 2011 21:33:42 +0000</pubDate>
			<dc:creator>RichardBest</dc:creator>
			<guid isPermaLink="false">35928@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi and many thanks David. Apologies if this is an ignorant question, but presumably I would replace case &#34;1&#34; at line 2 with the number of the form I want to target, e.g.,&#60;br /&#62;
&#34;case 7&#34;, and likewise for case 2 at line 11 etc?&#60;/p&#62;
&#60;p&#62;Thanks for your help.&#60;br /&#62;
Richard
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Smith on "Code to specify that a tag entered in a form should go to a custom taxonomy"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/code-to-specify-that-a-tag-entered-in-a-form-should-go-to-a-custom-taxonomy#post-35868</link>
			<pubDate>Wed, 21 Sep 2011 11:57:24 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">35868@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Richard,&#60;/p&#62;
&#60;p&#62;You can wrap this switch in another switch for the form ID with a case for each form.&#60;/p&#62;
&#60;p&#62;Psuedo Code&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;[php]
switch($form_id) {
case 1:
    switch($field_id) {
    case 1:
        // code
        break;
    case 2:
        // code
        break;
    }
case 2:
    switch($field_id) {
    case 3:
        // code
        break;
    case 4:
        // code
        break;
    }
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>

	</channel>
</rss>
