<?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: Update a custom field based on a form response</title>
		<link>https://legacy.forums.gravityhelp.com/topic/update-a-custom-field-based-on-a-form-response</link>
		<description>Gravity Support Forums Topic: Update a custom field based on a form response</description>
		<language>en-US</language>
		<pubDate>Sat, 04 Apr 2026 12:46:02 +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/update-a-custom-field-based-on-a-form-response" rel="self" type="application/rss+xml" />

		<item>
			<title>Chris Hajer on "Update a custom field based on a form response"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/update-a-custom-field-based-on-a-form-response#post-78423</link>
			<pubDate>Mon, 01 Oct 2012 22:45:06 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">78423@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I think you are going to have to split that string on the pipe and save the first part, the value, if that's what you want.  If you are doing this:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[php]
$sponsor_level = $entry[&#38;quot;3&#38;quot;] ;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;try this instead:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[php]
$sponsor_level_array = preg_split(&#38;quot;/\&#124;/&#38;quot;, $entry[&#38;#39;3&#38;#39;]);
$sponsor_level = $sponsor_level_array[0];&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;That will return the first part of the entry, before the pipe, the value.  &#60;/p&#62;
&#60;p&#62;There is probably a shorter way to do that but I can't put my finger on it right now.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>byjc on "Update a custom field based on a form response"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/update-a-custom-field-based-on-a-form-response#post-78338</link>
			<pubDate>Mon, 01 Oct 2012 13:00:46 +0000</pubDate>
			<dc:creator>byjc</dc:creator>
			<guid isPermaLink="false">78338@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks. I've almost got it worked out, except for one last issue with an Entry Object. Field 3 is a Product Drop-Down, so using $sponsor_level = $entry[&#34;3&#34;] is returning both the Value and the Price with a pipe between them. I've tried &#34;3,1&#34; but that doesn't work. Is it possible to return only the value field from that dropdown?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Update a custom field based on a form response"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/update-a-custom-field-based-on-a-form-response#post-78308</link>
			<pubDate>Mon, 01 Oct 2012 11:32:06 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">78308@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Can you echo the variables after you set each one to see if they are all populated as expected?&#60;/p&#62;
&#60;p&#62;However, I think the problem is in line 8.  $post is an array.  You need the post ID for update_post_meta.  Something like this instead:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[php]
update_post_meta($post-&#38;gt;ID, &#38;#39;sponsors&#38;#39;, $new_count);&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>byjc on "Update a custom field based on a form response"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/update-a-custom-field-based-on-a-form-response#post-78290</link>
			<pubDate>Mon, 01 Oct 2012 10:21:40 +0000</pubDate>
			<dc:creator>byjc</dc:creator>
			<guid isPermaLink="false">78290@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Not working quite yet. Here's what I have:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php add_action(&#38;quot;gform_after_submission_9&#38;quot;, &#38;quot;update_sponsor_count&#38;quot;, 10, 2);
			function update_sponsor_count($entry, $form){
			    //getting post and entry data
			    $post = get_post($entry[&#38;quot;post_id&#38;quot;]);
			    $sponsor_level = get_post($entry[&#38;quot;3&#38;quot;]);
			    //updating sponsor count
			    if ($sponsor_level == &#38;#39;sponsor1&#38;#39;) { $new_count = $sponsor_count + 1;}
			    update_post_meta($post, &#38;#39;sponsors&#38;#39;, $new_count);
			} ?&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I'm trying to update the 'sponsor' post meta. The $sponsor_count is previously defined in the post loop as the value of 'sponsor' prior to form submission. Not showing any php errors in the error log.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Update a custom field based on a form response"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/update-a-custom-field-based-on-a-form-response#post-78244</link>
			<pubDate>Mon, 01 Oct 2012 01:13:01 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">78244@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Did you get it working or did you need additional assistance?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>byjc on "Update a custom field based on a form response"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/update-a-custom-field-based-on-a-form-response#post-78220</link>
			<pubDate>Sun, 30 Sep 2012 22:04:40 +0000</pubDate>
			<dc:creator>byjc</dc:creator>
			<guid isPermaLink="false">78220@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks Chris
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Update a custom field based on a form response"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/update-a-custom-field-based-on-a-form-response#post-78206</link>
			<pubDate>Sun, 30 Sep 2012 20:39:27 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">78206@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;If you want to update an existing post (the post where the form is embedded) you can use the gform_after_submission hook and call update_post_meta to add or update the custom field value.&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://www.gravityhelp.com/documentation/page/Gform_after_submission&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/documentation/page/Gform_after_submission&#60;/a&#62;&#60;br /&#62;
&#60;a href=&#34;http://codex.wordpress.org/Function_Reference/update_post_meta&#34; rel=&#34;nofollow&#34;&#62;http://codex.wordpress.org/Function_Reference/update_post_meta&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>byjc on "Update a custom field based on a form response"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/update-a-custom-field-based-on-a-form-response#post-77953</link>
			<pubDate>Fri, 28 Sep 2012 15:22:37 +0000</pubDate>
			<dc:creator>byjc</dc:creator>
			<guid isPermaLink="false">77953@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I think I've worked out a solution for part what is described here, but still haven't resolved one key feature. When I form is submitted, I'd also like it to update a custom field for the current post that the form is displayed within. Is this doable?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>byjc on "Update a custom field based on a form response"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/update-a-custom-field-based-on-a-form-response#post-77535</link>
			<pubDate>Wed, 26 Sep 2012 16:13:40 +0000</pubDate>
			<dc:creator>byjc</dc:creator>
			<guid isPermaLink="false">77535@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I'm including a form within the template for an existing custom post type on a non-profit site. The custom post type will have a custom field for sponsors with a value of 0-5, and I want to both get that value for display in the form, as well as update the field when the form is submitted.&#60;/p&#62;
&#60;p&#62;For instance, a visitor to the site might see that there is 1 sponsor slot already taken, and they want to offer two more. I'd like the form to:&#60;/p&#62;
&#60;p&#62;1) Query the field to properly display how many sponsorships are available. (In this case, only 4, so it would display a drop down with 1-4.)&#60;br /&#62;
2) Assuming the user selects the number 2, for two sponsorships, the form would the update the custom field to add 2 to it, so that it would now display that 3 sponsorships have been taken for the next user.&#60;br /&#62;
3) To possibly confuse the issue, the number of sponsorships should be taken from a product quantity as it will also be processing their payment.&#60;/p&#62;
&#60;p&#62;Is this doable? And if so, any pointers on the proper code?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
