Hi @daylonf,
Gravity Forms offers a way to pre-populate your fields.
Pre-populated fields
If you edit your form, select a field, and then go to “Advanced”, you’ll find the option “Allow field to be populated dynamically”. When enabled, you can enter a parameter name. This allows you to add that parameter name to the query string of your URL, to fill that field.
For example, if you give it the name my_param, you can go to the page that holds your form, and add ?my_param=this+value. It should pre-populate your field. Using these params, you could generate a URL for your users that has all their information pre-populated.
If you want to go a more dynamic route, you can hook into the gform_field_value filter.
You can add a callback that receives the default value, the field instance, and the name of the parameter you configured. For example:
add_filter( 'gform_field_value', function( $default_value, $field, $param_name ) {
$user_id = rgget( 'user_id' );
//Retrieve the user information for the specified user ID.
$user_info = []; // Ideally cache this information.
switch ( $param_name )
{
case 'my_param':
return $user_info['info_key'] ?? '';
// case 'another_param':
//return $user_info['that_key'] ?? '';
default:
return $default_value; // Fall back to the default value.
}
}, 10, 3 );
This will allow you to add a ?user_id=ID param to your URL. The callback will then use that value to retrieve the user information from whatever you choose, and return the appropriate value, based on the param_name.
Note: This still requires you to enable the “Allow field to be populated dynamically” setting, and set a parameter name.
Prevent duplicate entry
To prevent a user from entering the information multiple times, you could add a unique identifier to your form, for example, their email address, and select “No duplicates” under the “General” field settings.
This prevents the same email address from being used a second time.
Hope this helps you out. If you have any question, feel free to contact me.
Kind regards,
Doeke