<?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: Create new category or add to existing</title>
		<link>https://legacy.forums.gravityhelp.com/topic/create-new-category-or-add-to-existing</link>
		<description>Gravity Support Forums Topic: Create new category or add to existing</description>
		<language>en-US</language>
		<pubDate>Sun, 05 Apr 2026 10:09:14 +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/create-new-category-or-add-to-existing" rel="self" type="application/rss+xml" />

		<item>
			<title>caseym on "Create new category or add to existing"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/create-new-category-or-add-to-existing#post-30221</link>
			<pubDate>Sun, 17 Jul 2011 15:46:56 +0000</pubDate>
			<dc:creator>caseym</dc:creator>
			<guid isPermaLink="false">30221@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks David, this worked perfectly!&#60;/p&#62;
&#60;p&#62;Casey
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Smith on "Create new category or add to existing"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/create-new-category-or-add-to-existing#post-30169</link>
			<pubDate>Sat, 16 Jul 2011 06:26:40 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">30169@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Caseym,&#60;/p&#62;
&#60;p&#62;The &#60;em&#62;post_category&#60;/em&#62; property of the &#60;strong&#62;$post_data&#60;/strong&#62; array is an array of IDs this post is assigned to. In order to add new categories to the post data you will need to a) retrieve the category's term ID and b) assign it as a new index in the existing array.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[php]
$post_data[&#38;#39;post_category&#38;#39;][] = 14;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;In regards to creating and assigning the post to a new category if the entered neighborhood does not exist, here are two functions that might be useful to you.&#60;/p&#62;
&#60;ol&#62;
&#60;li&#62;&#60;a href=&#34;http://codex.wordpress.org/Function_Reference/get_term_by&#34; rel=&#34;nofollow&#34;&#62;get_term_by&#60;/a&#62;&#60;br /&#62;
This will allow you to search for a term by the entered name.&#60;/li&#62;
&#60;li&#62;&#60;a href=&#34;http://codex.wordpress.org/Function_Reference/wp_insert_term&#34; rel=&#34;nofollow&#34;&#62;wp_insert_term&#60;/a&#62;&#60;br /&#62;
If the term does not exist, you can use this function to create it. It will return the term ID so you can assign it to the post category array.
&#60;/li&#62;
&#60;/ol&#62;</description>
		</item>
		<item>
			<title>caseym on "Create new category or add to existing"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/create-new-category-or-add-to-existing#post-30166</link>
			<pubDate>Fri, 15 Jul 2011 21:20:45 +0000</pubDate>
			<dc:creator>caseym</dc:creator>
			<guid isPermaLink="false">30166@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;I have a category dropdown on my form: State &#38;gt; Base. The user selects their base using this dropdown. In a separate text field, they write the name of their neighborhood. When the form is submitted, I want to take the neighborhood text and turn it into a category. So the post created by the form will be saved under: State &#38;gt; Base &#38;gt; Neighborhoods &#38;gt; Neighborhood Name. If the neighborhood already exists then the post will be saved in that category.&#60;/p&#62;
&#60;p&#62;I think I need to use gform_post_data to accomplish this but it's not working. This is what I have so far:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;#39;gform_post_data_6&#38;#39;, &#38;#39;update_cat&#38;#39;);
function update_cat($post_data){

    $post_data[&#38;#39;post_category&#38;#39;] .= &#38;#39;neighborhood&#38;#39;;

    return $post_data;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Any tips?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
