The gform_is_encrypted_field Gravity Forms PHP filter determines if an entry field is stored encrypted. You can use this hook to change the default behavior of decrypting fields that have been encrypted or to completely disable the process if checking for encrypted fields.
Usage
add_filter('gform_is_encrypted_field', 'your_function_name', 10, 3);
Parameters
- $is_encrypted (string) – Defaults to an empty string.
- $entry_id (int) – The current Entry ID.
- $field_id (int) – The current Field ID.
More information
See Gravity Forms Docs: gform_is_encrypted_field
Examples
Disable encryption check for all fields
This example disables the encryption check for all fields by returning false
.
add_filter('gform_is_encrypted_field', 'not_encrypted', 10, 3); function not_encrypted($is_encrypted, $entry_id, $field_id) { return false; }
Enable encryption check for specific field IDs
This example enables the encryption check only for fields with specific field IDs.
add_filter('gform_is_encrypted_field', 'enable_encryption_for_specific_fields', 10, 3); function enable_encryption_for_specific_fields($is_encrypted, $entry_id, $field_id) { $encrypted_field_ids = array(1, 2, 3); return in_array($field_id, $encrypted_field_ids); }
Disable encryption check for specific entry IDs
This example disables the encryption check for specific entry IDs.
add_filter('gform_is_encrypted_field', 'disable_encryption_for_specific_entries', 10, 3); function disable_encryption_for_specific_entries($is_encrypted, $entry_id, $field_id) { $disabled_entry_ids = array(100, 200, 300); return !in_array($entry_id, $disabled_entry_ids); }
Enable encryption check for specific form IDs and field IDs
This example enables the encryption check only for specific form IDs and field IDs.
add_filter('gform_is_encrypted_field', 'enable_encryption_for_specific_forms_and_fields', 10, 3); function enable_encryption_for_specific_forms_and_fields($is_encrypted, $entry_id, $field_id) { $encrypted_forms_and_fields = array( 1 => array(1, 2, 3), 2 => array(4, 5, 6) ); $form_id = GFAPI::get_entry($entry_id)['form_id']; return isset($encrypted_forms_and_fields[$form_id]) && in_array($field_id, $encrypted_forms_and_fields[$form_id]); }
Enable encryption check based on custom logic
This example enables the encryption check based on custom logic, such as the current user’s role.
add_filter('gform_is_encrypted_field', 'enable_encryption_based_on_custom_logic', 10, 3); function enable_encryption_based_on_custom_logic($is_encrypted, $entry_id, $field_id) { $user = wp_get_current_user(); return in_array('administrator', $user->roles); }