Last active
January 30, 2019 15:07
-
-
Save hiranthi/637b467fe8171d2270076b46e5309f48 to your computer and use it in GitHub Desktop.
Encrypt & decrypt Gravity Forms velden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated version: https://gist.github.com/hiranthi/ffcbae234edda3e08c6db13884c24450