Prevent Population Of Mapped Fields With The Saved Values

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.

Instructions

Code

Filename: gw-user-registration-prevent-populating-mapped-fields.php

<?php
/**
 * Gravity Wiz // Gravity Forms User Registration // Prevent Population Of Mapped Fields With The Saved Values
 * https://gravitywiz.com/
 *
 * 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.
 *
 * Instructions:
 *
 *  1. Install the snippet.
 *     https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
 */
add_action( 'gform_user_registration_user_data_pre_populate', function ( $mapped_fields, $form, $feed ) {
	// Replace "1" with the form ID you want to prevent the population of mapped fields.
	if ( $form['id'] !== 1 ) {
		return $mapped_fields;
	}

	// Replace "3" with the field ID you want to display empty.
	$mapped_fields[3] = '';

	// Want to overwrite all mapped fields? Uncomment the line below.
	// $mapped_fields = array();

	return $mapped_fields;
}, 10, 3 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.