<?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: Creating a Post within a Custom Post Type &#38; Taxonomy</title>
		<link>https://legacy.forums.gravityhelp.com/topic/creating-a-post-within-a-custom-post-type-taxonomy</link>
		<description>Gravity Support Forums Topic: Creating a Post within a Custom Post Type &amp; Taxonomy</description>
		<language>en-US</language>
		<pubDate>Sat, 04 Apr 2026 03:04:38 +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/creating-a-post-within-a-custom-post-type-taxonomy" rel="self" type="application/rss+xml" />

		<item>
			<title>Noel Green on "Creating a Post within a Custom Post Type &#38; Taxonomy"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/creating-a-post-within-a-custom-post-type-taxonomy#post-59471</link>
			<pubDate>Fri, 18 May 2012 17:39:02 +0000</pubDate>
			<dc:creator>Noel Green</dc:creator>
			<guid isPermaLink="false">59471@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Yes. I have that installed.&#60;/p&#62;
&#60;p&#62;I had not seen, however, that you could create dropdowns for people to choose a taxonomy from!&#60;/p&#62;
&#60;p&#62;Thank you. :D&#60;br /&#62;
That's not exactly how I was going to do it... but it works.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Peralty on "Creating a Post within a Custom Post Type &#38; Taxonomy"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/creating-a-post-within-a-custom-post-type-taxonomy#post-59469</link>
			<pubDate>Fri, 18 May 2012 17:27:44 +0000</pubDate>
			<dc:creator>David Peralty</dc:creator>
			<guid isPermaLink="false">59469@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Have you seen this third party add-on? &#60;a href=&#34;http://wordpress.org/extend/plugins/gravity-forms-custom-post-types/&#34; rel=&#34;nofollow&#34;&#62;http://wordpress.org/extend/plugins/gravity-forms-custom-post-types/&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Noel Green on "Creating a Post within a Custom Post Type &#38; Taxonomy"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/creating-a-post-within-a-custom-post-type-taxonomy#post-59463</link>
			<pubDate>Fri, 18 May 2012 17:01:23 +0000</pubDate>
			<dc:creator>Noel Green</dc:creator>
			<guid isPermaLink="false">59463@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I'm obviously putting the CSS class of &#34;add_lessonplans&#34; to the field which is pulling in their name.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Noel Green on "Creating a Post within a Custom Post Type &#38; Taxonomy"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/creating-a-post-within-a-custom-post-type-taxonomy#post-59462</link>
			<pubDate>Fri, 18 May 2012 17:00:50 +0000</pubDate>
			<dc:creator>Noel Green</dc:creator>
			<guid isPermaLink="false">59462@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;So I have a custom post type called &#34;Lesson Plans&#34; (i.e. &#34;lessonplans&#34;)&#60;/p&#62;
&#60;p&#62;Within that I have a taxonomy called &#34;Classes / Teachers&#34; (i.e. &#34;class&#34;)&#60;/p&#62;
&#60;p&#62;The taxonomies are the teacher's display names: Jane Smith, John Doe, etc., etc.&#60;/p&#62;
&#60;p&#62;I have a field that auto-populates to fill in the teacher's name based on the user who is using the form (i.e. Jane or John etc.)&#60;/p&#62;
&#60;p&#62;How do I get that field to post into the corresponding taxonomy?&#60;/p&#62;
&#60;p&#62;Here is the code I have so far...&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;add_action(&#38;#39;gform_post_submission&#38;#39;, &#38;#39;gform_add_lessonplans&#38;#39;, 10, 2);
function gform_add_lessonplans($entry, $form){

    if(!rgar($entry, &#38;#39;post_id&#38;#39;))
        return;

    $post_id = rgar($entry, &#38;#39;post_id&#38;#39;);
    $valid_cat_ids = get_term_ids();
    $cat_ids = array();

    foreach($form[&#38;#39;fields&#38;#39;] as $field){

        if(strpos($field[&#38;#39;cssClass&#38;#39;], &#38;#39;add_lessonplans&#38;#39;) === false)
            continue;

        foreach($entry as $key =&#38;gt; $value){

            if(intval($key) != $field[&#38;#39;id&#38;#39;] &#124;&#124; !in_array($value, $valid_cat_ids))
                continue;

            $cat_ids[] = (int) $value;

        }

    }

    wp_set_object_terms($post_id, $cat_ids, &#38;#39;class&#38;#39;, false);

}

function get_term_ids(){

    $categories = get_terms(&#38;#39;class&#38;#39;, &#38;#39;hide_empty=0&#38;#39;);
    $cat_ids = array();

    foreach($categories as $category)
        $cat_ids[] = $category-&#38;gt;term_id;

    return $cat_ids;
}

function print_rr($array){
    echo &#38;#39;&#38;lt;pre&#38;gt;&#38;#39;;
    print_r($array);
    echo &#38;#39;&#38;lt;/pre&#38;gt;&#38;#39;;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Thanks!
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
