Gform_username questions

Setting up user registration within an existing form and would like it to autocreate username using firstname + lastname. I’ve added gform_username to functions.php being sure to change form id to the id of the form I’m targeting.

This form has multiple pages/steps with the user filling out basic personal info including first name (2.3) and last name (2.6) on page 1. When they click next, they see username and password fields. However, username remains blank.

Am I misunderstanding usage or should the username be autopopulated at this point? Do I need to enable autocomplete on username field too?

I’ve cleared caches and tested in different browsers, but before I begin extensive troubleshooting, thought I’d check with brain trust here. Any insights appreciated.

The gform_username filter is not used to populate the username field. The filter only runs when the form is validated and when the feed is processed after the entry has been saved.

If you want to populate the username field on page two, you would need to use the gform_pre_render filter to add the input value to the $_POST e.g.

$_POST['input_3'] = rgpost( 'input_2_3' ) . rgpost( 'input_2_6' );

Hi Crucesignati,

You can also use the Live Merge tags feature of our GP Populate Anything Perk to set the username using the first name and last name values. You would set the default value of the Username field to the live merge tags of the first name and last name, like so, @{:2.3}.@{:2.6}, and this should get it working as you want. If you have any questions, you can contact us via our support form.

Best,

1 Like

Thank you, @samuel and @richardw8k! Very helpful.

@samuel - I was able to get Live Merge tags working for this as you describe. We can use this, but do you know if it’s possible to use lastname-{entry_id}? I tried various iterations of “@{:2.6}-{entry_id}” but it’s populating “lastname-” only.

Again, many thanks.

Hi @crucesignati,

The entry_id is generated when the form is submitted so it won’t work with the live merge tag. You may need a different approach to get this working for your use case. You can contact us via our support form so we can look at the setup and assist you to get it working.

Best,

Thank you, @samuel ! If we need to go that direction, I’ll ping you. Appreciate the help.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.