Gravity Perks // GP Unique ID // Unique ID as Site Address and Site Title
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 Site Address and Site Title | |
* | |
* 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 site address and/or site title to still pass validation. | |
* | |
*/ | |
add_filter( 'gform_user_registration_validation', 'gp_unique_id_for_site_validation', 11, 2 ); | |
function gp_unique_id_for_site_validation( $form, $feed ) { | |
$site_address_field_id = rgars( $feed, 'meta/multisite_options/site_address' ); | |
$site_name_field_id = rgars( $feed, 'meta/multisite_options/site_title' ); | |
foreach( $form['fields'] as &$field ) { | |
if( $field['type'] == 'uid' && in_array( $field['id'], array( $site_address_field_id, $site_name_field_id ) ) ) { | |
$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 Gist has been migrated to the Gravity Wiz Snippet Library:
https://github.com/gravitywiz/snippet-library/blob/master/gp-unique-id/gpuid-site-address-title-validation.php