Skip to content

Instantly share code, notes, and snippets.

@spivurno
Last active April 5, 2021 13:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save spivurno/aa4f7bbb66fed3300746 to your computer and use it in GitHub Desktop.
Save spivurno/aa4f7bbb66fed3300746 to your computer and use it in GitHub Desktop.
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;
}
@dwaine35
Copy link

dwaine35 commented Dec 1, 2016

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.

@spivurno
Copy link
Author

spivurno commented Apr 5, 2021

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