Skip to content

Commit 2a3a079

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 2a3a079

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
* Instructions:
9+
*
10+
* 1. Install the snippet.
11+
* https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
12+
*/
13+
add_action( 'gform_user_registration_user_data_pre_populate', function ( $mapped_fields, $form, $feed ) {
14+
// Replace "1" with the form ID you want to prevent the population of mapped fields.
15+
if ( $form['id'] !== 1 ) {
16+
return $mapped_fields;
17+
}
18+
19+
// Replace "3" with the field ID you want to display empty.
20+
$mapped_fields[3] = '';
21+
22+
// Want to overwrite all mapped fields? Uncomment the line below.
23+
// $mapped_fields = array();
24+
25+
return $mapped_fields;
26+
}, 10, 3 );

0 commit comments

Comments
 (0)