Skip to content

Commit b859487

Browse files
committed
gw-user-registration-prevent-populating-mapped-fields.php: Added a snippet to prevent mapped fields from being populated with saved values from the User Registration feed.
1 parent 7b4a0eb commit b859487

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Gravity Wiz // Gravity Forms User Registration // Prevent Population Of Mapped Fields With The Saved Values
4+
* https://gravitywiz.com/
5+
*
6+
* Prevent population of mapped fields with the saved values. This snippet prevent the population of mapped fields with the saved values while displaying the form.
7+
*/
8+
add_action( 'gform_user_registration_user_data_pre_populate', function ( $mapped_fields, $form, $feed ) {
9+
// Replace "1" with the form ID you want to prevent the population of mapped fields.
10+
if ( $form['id'] !== 1 ) {
11+
return $mapped_fields;
12+
}
13+
14+
// Replace "3" with the field ID you want to display empty.
15+
$mapped_fields[3] = '';
16+
17+
// Want to overwrite all mapped fields? Uncomment the line below.
18+
// $mapped_fields = array();
19+
20+
return $mapped_fields;
21+
}, 10, 3 );

0 commit comments

Comments
 (0)