Quick Gravity Forms (WordPress) calculation help

Job ID: 34973949

Budget: $10 – $30 USD

I want to create a username from the Gravity Forms "Name" object by concatenating first name and last name ... and then checking for uniqueness.

A Gravity Forms wizard should be able to knock this out very quickly.

I found (and like) this function (see code below): https://docs.gravityforms.com/gform_username/

My form number is 5, FirstName is 1.3 and LastName is 1.6. The Username (destination) field is 42

I need someone to help configure and make this work for me.

I use CodeSnippets to manage my custom functions.

Upon form submission the Username needs to be created, and then I will be using Gravity Forms "User Registration Add-On" to create the WordPress user.

=======
They suggest a call of:
$username = gf_apply_filters( 'gform_username', $form['id'], $username, $feed, $form, $entry );




// Change 8 in gform_username_8 to your form id number.
add_filter( 'gform_username_8', 'auto_username', 10, 4 );
function auto_username( $username, $feed, $form, $entry ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );
// Update 2.3 and 2.6 with the id numbers of your Name field inputs. e.g. If your Name field has id 1 the inputs would be 1.3 and 1.6
$username = strtolower( rgar( $entry, '2.3' ) . rgar( $entry, '2.6' ) );

if ( empty( $username ) ) {
GFCommon::log_debug( __METHOD__ . '(): Value for username is empty.' );
return $username;
}

if ( ! function_exists( 'username_exists' ) ) {
require_once( ABSPATH . WPINC . '/registration.php' );
}

if ( username_exists( $username ) ) {
GFCommon::log_debug( __METHOD__ . '(): Username already exists, generating a new one.' );
$i = 2;
while ( username_exists( $username . $i ) ) {
$i++;
}
$username = $username . $i;
GFCommon::log_debug( __METHOD__ . '(): New username: ' . $username );
};

return $username;
}
Related categories: PHP WordPress Gravity Forms