<?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: gform_username bug</title>
		<link>https://legacy.forums.gravityhelp.com/topic/gform_username-bug</link>
		<description>Gravity Support Forums Topic: gform_username bug</description>
		<language>en-US</language>
		<pubDate>Mon, 20 Apr 2026 03:22:36 +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/gform_username-bug" rel="self" type="application/rss+xml" />

		<item>
			<title>Alex Cancado on "gform_username bug"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/gform_username-bug#post-81768</link>
			<pubDate>Wed, 17 Oct 2012 14:22:03 +0000</pubDate>
			<dc:creator>Alex Cancado</dc:creator>
			<guid isPermaLink="false">81768@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;It looks like you simply need to replace &#34;input_12_41_3&#34; with &#34;input_41_3&#34; and &#34;input_12_41_6&#34; with &#34;input_12_41_6&#34; from the original code you posted. Let me know if that doesn't do the trick.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>phase00 on "gform_username bug"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/gform_username-bug#post-81581</link>
			<pubDate>Wed, 17 Oct 2012 00:51:28 +0000</pubDate>
			<dc:creator>phase00</dc:creator>
			<guid isPermaLink="false">81581@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I've run in to a bit of a problem with &#60;code&#62;gform_username&#60;/code&#62;. When I use the code provided on the documents: &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;#39;gform_username&#38;#39;, &#38;#39;auto_username&#38;#39;);
function auto_username($username){

    $username = strtolower(rgpost(&#38;#39;input_12_41_3&#38;#39;) . rgpost(&#38;#39;input_12_41_6&#38;#39;));

    if(empty($username))
        return $username;

    if(!function_exists(&#38;#39;username_exists&#38;#39;))
        require_once(ABSPATH . WPINC . &#38;quot;/registration.php&#38;quot;);

    if(username_exists($username)){
        $i = 2;
        while(username_exists($username . $i)){
            $i++;
        }
        $username = $username . $i;
    };

    return $username;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;When I submit the form, the field I set as &#34;username&#34; from the user registration always returns a validation error stating &#34;username must not be empty&#34; (or something to that effect). This happened for any field I set as &#34;username&#34;. If I changed the $_POST[&#34;input_42&#34;] == 'some random string'; it still broke. Upon commenting the above code, the form worked perfectly fine. So it leads me to believe there's an issue with the function (I haven't dug in to the code).&#60;/p&#62;
&#60;p&#62;As a work-around I created a hidden field called uid which I set as the &#34;username&#34;. I had to pre-populate this field via &#60;code&#62;gform_field_value_uid&#60;/code&#62; so it was not empty, then use a &#60;code&#62;gform_pre_submission&#60;/code&#62; to repopulate the uid &#60;code&#62;$_POST&#60;/code&#62; value to what I wanted the username to actually be.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_action(&#38;quot;gform_pre_submission&#38;quot;, &#38;quot;populate_username&#38;quot;);
function populate_username($form){
    $_POST[&#38;quot;input_42&#38;quot;] = $_POST[&#38;quot;input_41_3&#38;quot;] . $_POST[&#38;quot;input_41_6&#38;quot;];
    // input_41_3 &#38;amp; input_41_6 are first &#38;amp; last name based on advanced name field.
}

add_filter(&#38;quot;gform_field_value_uid&#38;quot;, &#38;quot;populate_uid&#38;quot;);
function populate_uid($value){
   return md5(rand_string(20));
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>

	</channel>
</rss>
