SHARE
TWEET

gf_encrypt

a guest Aug 6th, 2011 185 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_filter("gform_save_field_value", "save_field_value", 10, 4);
  2. function save_field_value ($value, $lead, $field, $form) {
  3.     if (strpos(strtolower($form['title']), 'confidential') !== FALSE && strpos(strtolower($field['label']), 'program date') === FALSE) {
  4.          switch ($field['type']) {
  5.               case 'radio':
  6.               case 'select':
  7.               case 'checkbox':
  8.               break;
  9.               default:
  10.                   $value = '%%enc%%' . custom_encrypt_func($value) . '%%end%%';
  11.          }
  12.     }
  13.     return $value;
  14. }
  15.  
  16. add_filter("gform_get_field_value", "get_field_value", 10, 3);
  17. add_filter("gform_entry_field_value", "get_field_value", 10, 4);
  18. function get_field_value ($value, $lead, $field, $form=NULL) {
  19.     if (is_array($value)) {
  20.         foreach ($value as &$val) {
  21.             $val = _get_one_field_value($val);
  22.         }
  23.     } else {
  24.         $value = _get_one_field_value($value);
  25.     }
  26.     return $value;
  27. }
  28.  
  29. function _get_one_field_value ($value) {
  30.     $value = preg_replace_callback(
  31.         '/%%enc%%(.+?)%%end%%/',
  32.         create_function(
  33.             '$matches',
  34.             'return custom_decrypt_func($matches[1]);'
  35.         ),
  36.         $value
  37.     );
  38.     return $value;
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top