Last active
April 5, 2021 13:27
-
-
Save spivurno/aa4f7bbb66fed3300746 to your computer and use it in GitHub Desktop.
Gravity Perks // GP Unique ID // Unique ID as Username
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
👉 This Gist has been migrated to the Gravity Wiz Snippet Library:
https://github.com/gravitywiz/snippet-library/blob/master/gp-unique-id/gpuid-username-validation.php
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.