Let’s say you have a form that collects sensitive data like email address, user government ID, etc.
By default, when an entry is submitted all those details are exposed in the individual entry on the WordPress admin.
Let’s also say that you delegate some tasks on your website and have collaborators that can access the form entries in the WordPress admin.
You may probably want to restrict some entry details from them, to protect your user’s privacy.
Something you can do is filter the field values displayed for each entry.
You can intercept the field value and change it to whatever you prefer.
Gravity Forms provide two useful filters for this matter:
gform_entries_field_value. https://docs.gravityforms.com/gform_entries_field_value/.
gform_entry_field_value. https://docs.gravityforms.com/gform_entry_field_value/.
The difference between each is that the first one, gform_entries_field_value, intercepts the field values in the Entries list.
The second one, gform_entry_field_value, filters the field values in the Individual entry page.
Here is a sample snippet to protect the field value on the Entries list:
add_filter( 'gform_entries_field_value', 'protect_specific_field_from_entries_list', 10, 4 );
function protect_specific_field_from_entries_list( $value, $form_id, $field_id, $entry ) {
// Replace field_id with the ID of the field you want to hide
if ( $field_id == 17 ) {
return 'PROTECTED';
}
return $value;
}
You can reference the field or fields by the field ID.
Then, on every match, return a custom value.
Here is a sample snippet to protect the field value on the individual entry post:
add_filter( 'gform_entry_field_value', 'protect_field_value_in_entry_detail', 10, 4 );
function protect_field_value_in_entry_detail( $value, $field, $entry, $form ) {
// Replace $field->id with the ID of the field you want to protect.
if ( $field->id == 17 ) {
$field->label = 'PROTECTED';
return 'PROTECTED';
}
return $value;
}
The results should be as follows:
If you inspect the elements in the browser’s dev console, the rendered values correspond to your new custom values.
Check the documentation links below: