Skip to content

Instantly share code, notes, and snippets.

@spivurno
Created October 12, 2017 13:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spivurno/ad05a8543ea6b2a6a4845f1caf1fe675 to your computer and use it in GitHub Desktop.
Save spivurno/ad05a8543ea6b2a6a4845f1caf1fe675 to your computer and use it in GitHub Desktop.
Gravity Perks // GP Unique ID // Use Unique ID as User Registration Password
<?php
/**
* Gravity Perks // GP Unique ID // Use Unique ID as User Registration Password
* http://gravitywiz.com/documentation/gravity-forms-unique-id/
*/
add_filter( 'gform_userregistration_feed_settings_fields', function( $fields, $form ) {
foreach( $fields['user_settings']['fields'] as &$field ) {
if( $field['name'] == 'password' ) {
$field['args']['input_types'][] = 'uid';
}
}
return $fields;
}, 10, 2 );
@g-rzegorz
Copy link

g-rzegorz commented Mar 5, 2020

Hi, Is it possible to generate a password, username and email address with UniqueID and forward it to the Gravity Forms User Registration Addon? In the form I created UniqueID-email (I added suffix @ exaemple.com), UniqueID-password, UniqueID-username.

I am completing the test form and all generated unique data are correctly saved.

However, if I activate User Registratio for this form, unfortunately I get an error that the form has not been completed correctly.

Of course, I added your code + additionally this:

if ($ field ['name'] == 'email') {
$ field ['args'] ['input_types'] [] = 'uid';
}
if ($ field ['name'] == 'username') {
$ field ['args'] ['input_types'] [] = 'uid';
}

Then in the Registration Settings of the form I can assign those generated by UniqueID to the username, password and email respectively, but unfortunately I get an error when trying to submit such a form.
In the source code of the page I see:

"validation_message_1_5" class = "gfield_description validation_message" aria-live = "polite"> The email address can not be empty

So as if the email address was empty. I'm doing something wrong?

@spivurno
Copy link
Author

spivurno commented Mar 6, 2020

Hey @g-rzegorz, hit us up via support and we'll be happy to dig in: http://gravitywiz.com/support/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment