DEVELOPER FUNCTIONS
gfef_developer_decrypt($entry_id, $field_id, $format)
Returns decrypted Gravity Forms field value or false, and can optionally attempt to have Gravity Forms format the display.
variables:
$entry_id – Required. The entry ID
$field_id – Required. The field ID
$format – Optional. Set to true to let gravity forms attempt to HTML format the data.
examples to return decrypted field value:
$field_3_value = gfef_developer_decrypt(4, 3);
$field_7_value = gfef_developer_decrypt(4, 7, true);
gfef_text_encrypt($text, $key)
Encrypts any text/string value.
variables:
$text – Required. The text/string to encrypt.
$key – Optional. Use a custom encryption key instead of the current password/key combination.
examples to encrypt text/string value:
$encrypted_value = gfef_text_encrypt(‘hello’);
$encrypted_value = gfef_text_encrypt($string_variable);
$encrypted_value = gfef_text_encrypt(‘hello’, ‘mysecretkey’);
gfef_text_decrypt($text, $key)
Decrypts text/string value encrypted by gfef_text_encrypt (same key must be used).
variables:
$text – Required. The text/string to decrypt.
$key – Optional. Use a custom decryption key instead of the current password/key combination.
examples to decrypt text/string value:
$encrypted_value = gfef_text_decrypt(‘hello’);
$encrypted_value = gfef_text_decrypt($string_variable);
$encrypted_value = gfef_text_decrypt(‘hello’, ‘mysecretkey’);
CODE SNIPPETS
Code snippets should be placed in the “functions.php” file of a child theme to your main theme to avoid being overwritten by plugin or theme updates.
Auto decrypt encrypted field data on submission. Useful to decrypt field data passed in with encrypted merge tags.
-Replace “FORM ID” and “FEILD ID” with the desired form and feild ID’s
Single field example.
add_filter(‘gform_save_field_
function gfef_decrypt_merge_tag_
if ($field->formId == FORM ID && $field->id == FIELD ID) {
$value = gfef_decrypt($value);
}
return $value;
}
Multiple form and field example.
add_filter(‘gform_save_field_
function gfef_decrypt_merge_tag_
if ($field->formId == FORM ID && $field->id == FIELD ID || $field->formId == FORM ID && $field->id == FIELD ID) {
$value = gfef_decrypt($value);
}
return $value;
}
Single form and multiple field example.
add_filter(‘gform_save_field_
function gfef_decrypt_merge_tag_
if ($field->formId == FORM ID && ($field->id == FIELD ID || $field->id == FIELD ID || $field->id == FIELD ID)) {
$value = gfef_decrypt($value);
}
return $value;
Decrypt only specific fields by checking for matching field id(s) to decrypt. For multipart fields, use the full id.input format such as 1.3 – Change the $select_field_ids array field ids to match the desired field id(s) to decrypt.
add_filter(‘fg_entryautomation_export_field_value’, function($value, $form, $field_id, $entry, $task) {
if ((get_option(‘gfe_restricted’) && $value == get_option(‘gfe_restricted’)) || (get_option(‘gfe_hidevalue’) && $value == get_option(‘gfe_hidevalue’))) {
$select_field_ids = array(1,2,2.3,4,5.1); //field ids to decrypt
if (in_array($field_id, $select_field_ids, TRUE)) {
$value = gfef_get_raw_field_value($entry[‘id’], $field_id);
return gfef_text_decrypt($value);
}
}
return $value;
}, 10, 5);