<?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: Populate data before submit</title>
		<link>https://legacy.forums.gravityhelp.com/topic/populate-data-before-submit</link>
		<description>Gravity Support Forums Topic: Populate data before submit</description>
		<language>en-US</language>
		<pubDate>Mon, 20 Apr 2026 02:30:56 +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/populate-data-before-submit" rel="self" type="application/rss+xml" />

		<item>
			<title>Chris Hajer on "Populate data before submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/populate-data-before-submit#post-76173</link>
			<pubDate>Tue, 18 Sep 2012 20:34:12 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">76173@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Assuming the field has checked &#34;Allow this field to be populated dynamically&#34; and it uses the parameter name of &#34;lidnummer&#34; this should work.  Have you done both those things?&#60;/p&#62;
&#60;p&#62;However, your original question was about the uniqueness of this value.  I don't know of a better hook to populate the field with.  But instead of generating a number like this, you might need to assign numbers from a list, so that each number is used only once.  Or, you might be able to check that the number does not exist by using the gform_validation_hook.  Since it's nothing the user did wrong, you probably don't want to show an error to them, but just assign the next number, and repeat the process.&#60;/p&#62;
&#60;p&#62;The most foolproof method would be to read the number from a list of numbers and assign it like that.  When you generate a number like this there are bound to be situations where you run into this problem.&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://en.wikipedia.org/wiki/Race_condition&#34; rel=&#34;nofollow&#34;&#62;http://en.wikipedia.org/wiki/Race_condition&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>fitbrand on "Populate data before submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/populate-data-before-submit#post-75877</link>
			<pubDate>Mon, 17 Sep 2012 14:48:28 +0000</pubDate>
			<dc:creator>fitbrand</dc:creator>
			<guid isPermaLink="false">75877@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Do i need to use different filter?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>fitbrand on "Populate data before submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/populate-data-before-submit#post-75720</link>
			<pubDate>Sun, 16 Sep 2012 18:22:30 +0000</pubDate>
			<dc:creator>fitbrand</dc:creator>
			<guid isPermaLink="false">75720@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Chris,&#60;/p&#62;
&#60;p&#62;Using the following line of code:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;add_filter(&#38;quot;gform_field_value_lidnummer&#38;quot;, &#38;quot;populate_lidnummer&#38;quot;);&#60;/code&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Populate data before submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/populate-data-before-submit#post-75692</link>
			<pubDate>Sun, 16 Sep 2012 15:26:41 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">75692@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Which hook or filter and using to call your function currently?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>fitbrand on "Populate data before submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/populate-data-before-submit#post-75676</link>
			<pubDate>Sun, 16 Sep 2012 14:03:11 +0000</pubDate>
			<dc:creator>fitbrand</dc:creator>
			<guid isPermaLink="false">75676@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Guys,&#60;/p&#62;
&#60;p&#62;I'm trying to build a nice registration form where users receive a unique (autoincrement) username. Something like:&#60;/p&#62;
&#60;p&#62;t000001&#60;br /&#62;
t000002&#60;br /&#62;
etc..&#60;/p&#62;
&#60;p&#62;I use the pre-populate feature and have the following code in my functions.php&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php

function populate_lidnummer($value){
	global $wpdb;
	$usernames = $wpdb-&#38;gt;get_results(&#38;quot;SELECT ID, user_url FROM $wpdb-&#38;gt;users ORDER BY ID DESC LIMIT 1&#38;quot;);

	foreach ($usernames as $username) {
		$lastuser = $username-&#38;gt;ID;
		$newuser_temp = $lastuser + 1;

		$num = strlen($newuser_temp);
		$max = 5;
		$zeros = $max - $num;

		return &#38;#39;t&#38;#39; . $newuser2 = str_repeat(&#38;quot;0&#38;quot;,$zeros).&#38;quot;&#38;quot;.$newuser_temp;;
	}
}?&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;This is not ideal because when several people filling out the form there is a problem with the uniqueness of the username. &#60;/p&#62;
&#60;p&#62;Now i thought it might be easier to populate the field just before the users hitting the submit button on the registration page. So the most recent data is populated from the database. &#60;/p&#62;
&#60;p&#62;How can i do this?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
