gform_ability_hidden_field_ids

Description

The gform_ability_hidden_field_ids filter hides sensitive fields from AI agents. Field IDs you return are stripped from entries-get entries-search responses, and any search or sort that references a hidden field is refused with a clear error, so an agent can’t infer values by filtering on them.

Note: A whole-field ID (4) also hides its sub-inputs (4.3, etc.); an input ID (7.1) hides just that input.

Usage

add_filter( 'gform_ability_hidden_field_ids', 'your_function_name', 10, 2 );

Parameters

ParameterTypeDescription
$field_idsstring[]The field or input IDs to hide from AI agents. Empty by default.
$form_idintegerThe ID of the form being queried.

Examples

Hide Specific Fields on a Form.

// Hide the SSN field (4) and the phone's first input (7.1) on form 5.
add_filter( 'gform_ability_hidden_field_ids', function ( $ids, $form_id ) {
	if ( 5 === $form_id ) {
		$ids[] = '4';
		$ids[] = '7.1';
	}
	return $ids;
}, 10, 2 );

Hide Fields Flagged for Personal-Data Erasure.

// Or: hide every field flagged for personal-data erasure, on all forms.
add_filter( 'gform_ability_hidden_field_ids', function ( $ids, $form_id ) {
	$form = GFAPI::get_form( $form_id );
	foreach ( (array) rgar( $form, 'fields' ) as $field ) {
		if ( ! empty( $field->personalDataErase ) ) {
			$ids[] = (string) $field->id;
		}
	}
	return $ids;
}, 10, 2 );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

This filter is located in gravityforms/includes/abilities/handlers/class-gf-abilities-handler-entries.php

Since

The filter was added in Gravity Forms 3.1.0