<?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: How to get form id?</title>
		<link>https://legacy.forums.gravityhelp.com/topic/how-to-get-form-id</link>
		<description>Gravity Support Forums Topic: How to get form id?</description>
		<language>en-US</language>
		<pubDate>Sun, 19 Apr 2026 19:05:43 +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/how-to-get-form-id" rel="self" type="application/rss+xml" />

		<item>
			<title>Chris Hajer on "How to get form id?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/how-to-get-form-id#post-32322</link>
			<pubDate>Thu, 11 Aug 2011 17:02:50 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">32322@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;UPDATE:&#60;/p&#62;
&#60;p&#62;Michelle has posted revised code here:&#60;br /&#62;
&#60;a href=&#34;http://www.gravityhelp.com/forums/topic/saving-a-form#post-32318&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/forums/topic/saving-a-form#post-32318&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Michelle on "How to get form id?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/how-to-get-form-id#post-32264</link>
			<pubDate>Wed, 10 Aug 2011 19:08:55 +0000</pubDate>
			<dc:creator>Michelle</dc:creator>
			<guid isPermaLink="false">32264@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;You rock!!  Thank you!&#60;/p&#62;
&#60;p&#62;Unfortunately I had to hack a bit of the core code to get everything working just the way I needed it to, but good news is, I think I now have a way to link my saved form to a logged-in user's profile (so the user can come back and edit the form / resubmit later).  In any case this is working for me. :-)&#60;/p&#62;
&#60;p&#62;Here's what I had to do to achieve it:&#60;/p&#62;
&#60;p&#62;UPDATE - see this post for a revised solution:&#60;br /&#62;
&#60;a href=&#34;http://www.gravityhelp.com/forums/topic/saving-a-form#post-32318&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/forums/topic/saving-a-form#post-32318&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;&#60;strike&#62;
&#60;ol&#62;
&#60;li&#62;In your form, go into each field's Advanced tab and click &#34;Allow Field to be Populated Dynamically. Enter a parameter name - it can be anything, but should be unique.&#60;/li&#62;
&#60;li&#62;Change line 909 of forms_model.php to read:&#60;br /&#62;
&#60;code&#62;return apply_filters(&#38;quot;gform_field_value_$name&#38;quot;, apply_filters(&#38;quot;gform_field_value&#38;quot;, $value, $name));&#60;/code&#62; &#60;/li&#62;
&#60;li&#62;Add the following to your theme's functions.php file:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;// RETRIEVE PARAMETER_NAME FOR FIELDS AND ADD TO WP_USERMETA
add_action(&#38;#39;gform_post_submission&#38;#39;, &#38;#39;save_entry_values&#38;#39;, 10, 2);
function save_entry_values($entry, $form){
    $userid = $entry[&#38;#39;created_by&#38;#39;]; // retrieve user ID
    $submitted_info = array();

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

        $value = RGFormsModel::get_lead_field_value($entry, $field);

        if($value) {
            $submitted_info[] = array($field[&#38;#39;inputName&#38;#39;] =&#38;gt; $value); // retrieves parameter_names values
            update_user_meta($userid, $field[&#38;#39;inputName&#38;#39;], $value); // stores parameter_name values in wp_usermeta table
        }
    }
}

// RUN REVISED GFORM_FIELD_VALUE_YOUR_PARAMETER FILTER
add_filter(&#38;#39;gform_field_value&#38;#39;, &#38;#39;populate_user_meta&#38;#39;, 10, 2);
function populate_user_meta($value, $name){
    global $user_ID;
    $field_user_meta = get_the_author_meta($name, $user_ID);
    return $field_user_meta;
}&#60;/code&#62;&#60;/pre&#62;
&#60;/li&#62;
&#60;li&#62;Now when logged-in users fill out a form, they should be able to return to that same form later and have all their previous answers pre-populated.&#60;/li&#62;
&#60;/ol&#62;
&#60;p&#62;The way the filter is rewritten should allow users to use both the gform_field_value filter and the original gform_field_value_your_parameter filter - the latter will overwrite the former.&#60;br /&#62;
&#60;/strike&#62;&#60;br /&#62;
Let me know if you can think of a better way to do this - any of it - and/or if there's a way I can move that rewritten filter into my local functions.php file. I hate to edit the core code, just couldn't see a way around it in this instance.&#60;/p&#62;
&#60;p&#62;Thanks again for your help!&#60;/p&#62;
&#60;p&#62;Michelle
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Smith on "How to get form id?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/how-to-get-form-id#post-32257</link>
			<pubDate>Wed, 10 Aug 2011 17:08:49 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">32257@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Michelle,&#60;/p&#62;
&#60;p&#62;The FIELD_ID is actually not a property of the entry object. It is listed to imply that using the field ID you can get the submitted value of the desired field (ie $entry[10]). Here is a some code that will retrieve the submitted values from the entry and aggregate them into an array (titled $submitted_info in the snippet). You can combine this code with the previously provided code.&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://pastie.org/2352331&#34; rel=&#34;nofollow&#34;&#62;http://pastie.org/2352331&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Michelle on "How to get form id?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/how-to-get-form-id#post-32251</link>
			<pubDate>Wed, 10 Aug 2011 16:26:48 +0000</pubDate>
			<dc:creator>Michelle</dc:creator>
			<guid isPermaLink="false">32251@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks David!! That works great for getting a specific field value from the form. &#60;/p&#62;
&#60;p&#62;Do you know, is there any way to retrieve all the field name/value pairs in an array? I thought field_id would do the trick based on this from the &#60;a href=&#34;http://www.gravityhelp.com/documentation/page/Entry_Object&#34; rel=&#34;nofollow&#34;&#62;entry_object page&#60;/a&#62;:&#60;/p&#62;
&#60;p&#62;FIELD_ID&#60;br /&#62;
(string) The value for all submitted fields can be retrieved by using the Field Id as the key to the $entry array.&#60;/p&#62;
&#60;p&#62;But maybe not? Thanks again,&#60;/p&#62;
&#60;p&#62;Michelle
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Smith on "How to get form id?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/how-to-get-form-id#post-32249</link>
			<pubDate>Wed, 10 Aug 2011 16:09:07 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">32249@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Michelle,&#60;/p&#62;
&#60;p&#62;Should the entry data be added to the user submitting the form or a specific user? The &#60;strong&#62;gform_post_submission&#60;/strong&#62; hook passes the &#60;strong&#62;$entry&#60;/strong&#62; variable (&#60;a href=&#34;http://www.gravityhelp.com/documentation/page/Gform_post_submission&#34; rel=&#34;nofollow&#34;&#62;documentation here&#60;/a&#62;). If the submitting user is logged in at the time of the submission their user ID will be included in the &#60;strong&#62;$entry&#60;/strong&#62; in the &#60;em&#62;created_by&#60;/em&#62; property. Here is a start:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://pastie.org/2352056&#34; rel=&#34;nofollow&#34;&#62;http://pastie.org/2352056&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Michelle on "How to get form id?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/how-to-get-form-id#post-32246</link>
			<pubDate>Wed, 10 Aug 2011 15:34:51 +0000</pubDate>
			<dc:creator>Michelle</dc:creator>
			<guid isPermaLink="false">32246@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
I'm trying to create a function which will add a field to the user metadata table on form submission. I'd like that field to contain an array of all the fields/responses in the submitted form. &#60;/p&#62;
&#60;p&#62;I tried using the gform_post_submission action hook and setting $form_contents = $entry['field_id'] as described on this page: &#60;a href=&#34;http://www.gravityhelp.com/documentation/page/Entry_Object&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/documentation/page/Entry_Object&#60;/a&#62; &#60;/p&#62;
&#60;p&#62;But no go. Any ideas on how to get this working? I suspect I'm trying to get the form/field contents in the wrong way. Here's my current function:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_action(&#38;quot;gform_post_submission&#38;quot;, &#38;quot;set_additional_user_fields&#38;quot;);
function set_additional_user_fields($user_id) {
    $form_contents = $entry[&#38;#39;field_id&#38;#39;];
    add_user_meta($user_id, &#38;#39;form_info&#38;#39;, $form_contents);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Thanks for your help!
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
