'How to Fix Gravity Forms Unique ID as Username Snippet
I wanted to create a unique ID as a username with Gravity Forms and purchased the Gravity Perks plugin and the Unique ID add-on. Gravity Wiz stated that normally such attempt will cause a validation error and that I need to apply a custom code by adding it to the snippet. I downloaded the snippet plugin, then I copied and pasted the code given by Gravity Wiz. However, it told me that there's an error with my code and I cannot activate it. Can you help me how to fix this problem? I'm not a tech person, so asking in this forum is my last resort. Thanks for helping me out!
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;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
