Skip to content

Instantly share code, notes, and snippets.

@hiranthi hiranthi/decrypt-2.php
Last active Jan 30, 2019

Embed
What would you like to do?
Encrypt & decrypt Gravity Forms velden
<?php
# Like on: https://docs.gravityforms.com/gform_get_input_value/
add_filter( 'gform_get_input_value', 'gf_custom_decode_field', 10, 4 );
function gf_custom_decrypt_field( $value, $entry, $field, $input_id )
{
return GFCommon::decrypt( $value );
}
// end gf_custom_decrypt_field
<?php
# Like on: https://docs.gravityforms.com/gform_get_input_value/
add_filter( 'gform_get_input_value', 'gf_custom_decode_field', 10, 4 );
function gf_custom_decrypt_field( $value, $entry, $field, $input_id )
{
# Add a check to see if a field has to be decrypted,
# because it's possible you're adding this after already having entries
$date_implemented = '2018-03-18 09:00:00'; # format: yyyy-mm-dd hh:mi:ss
$date_entry = rgar( $entry, 'date_created' );
# Entry is from after implementing encrypting entries
if ( strtotime( $date_entry ) >= $date_implemented )
return GFCommon::decrypt( $value );
# Entry is from before implementing encrypting entries
return $value;
}
// end gf_custom_decrypt_field
<?php
# Like on: https://docs.gravityforms.com/gform_save_field_value/
add_filter( 'gform_save_field_value', 'gf_custom_save_field_value', 10, 4 );
function gf_custom_save_field_value( $value, $lead, $field, $form )
{
return GFCommon::encrypt( $value );
}
// end gf_custom_save_field_value
@hiranthi

This comment has been minimized.

Copy link
Owner Author

commented Jan 30, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.