AI Summary
Description
The wpforms_entry_preview_fields
filter lets you modify the fields displayed in the Entry Preview. This can be useful for hiding empty fields or rearranging the preview data before it is displayed. You can use this filter to hide fields without values, adjust labels, or completely remove specific fields from the preview display.
parameter | type | description |
---|---|---|
$fields | array | Entry preview fields data. Each field includes its ID, label, and value. |
$form_data | array | Form ID. |
Source
wpforms\src\Pro\Forms\Fields\EntryPreview\Field.php
Example
/**
* Hide empty fields in the entry preview.
*/
function wpf_dev_hide_empty_preview( $fields, $form_data ) {
$fields = array_filter( $fields, function( $field ) {
return ! empty( $field['value'] );
});
return $fields;
}
add_filter( 'wpforms_entry_preview_fields', 'wpf_dev_hide_empty_preview', 10, 2 );