Gravity Perks // GP Unique ID // Unique ID as Username
<?php | |
/** | |
* Gravity Perks // GP Unique ID // Unique ID as Username or Site Address | |
* | |
* The Unique ID field is populated on submission, after validation. This snippet runs post-validation to allow User Registration feeds with a Unique ID | |
* field mapped as the username to still pass validation. | |
* | |
*/ | |
add_filter( 'gform_user_registration_validation', 'gp_unique_id_for_username_validation', 11, 2 ); | |
function gp_unique_id_for_username_validation( $form, $feed ) { | |
$username_field_id = rgars( $feed, 'meta/username' ); | |
$site_address_field_id = rgars( $feed, 'meta/multisite_options/site_address' ); | |
foreach( $form['fields'] as &$field ) { | |
if( in_array( $field['id'], array( $username_field_id, $site_address_field_id ) ) && $field['type'] == 'uid' ) { | |
$field['failed_validation'] = false; | |
} | |
} | |
return $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Hello All,
I am in desperate need of this plugin to add to my gravity forms wordpress powered website. Can someone please let me know where would I add this code so that I can map th unique id to the username field in wordpress. Thanks in advance.