The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Hook to modify value when editing or viewing

Labels

This Discussion is public

Notifications

I've added some hooks to encrypt data for certain fields when a form is created or updated.  Works like a charm.   See the attachment that shows the form entries.  For this, I'm using the following two hooks.

  • frm_add_entry_meta
  • frm_after_update_entry

When the information is displayed in a view, the encrypted content is replaced with "Encrypted".  Working like a charm. See the attachment with a small view in the form of a list.  I'm using the following hook.

  • frmpro_fields_replace_shortcodes

However, when I go to edit the form, I need to decrypt the field and present it back to the user.  See the attachment with the encrypted blob in the form.  I'm sure the hook is there, but I could really use a pointer to which one it is.


Attachments:

I found the following hook... it has let me display the unencrypted value and even throw a snazzy little decrypted icon in front of it.

frm_setup_edit_fields_vars

I'm loving this product but I have to say that the hook names leave a little something to be desired.

 

If there is a better way to do this folks, please let me know.  I'm just stumbling around as I test this tool out for larger uses.

Well, the frm_setup_edit_fields_vars hook seems to be the right hook. When I update an entry, the data is re-encrypted and stored properly. HOWEVER, it fails when the page reloads after a page update.

When I review the $values['value'] string it appears to be pre-encrypted string. This leads me to believe it gathers $values['value'] from $_POST.

My thought was to just grab it directly from the db using the FrmEntryMeta::get_entry_meta class but when I do it completely fails. I get an undefined method error. So... I'm not sure the best course of action.

add_filter('frm_setup_edit_fields_vars', 'frm_show_encrypted_field', 20, 3);
function frm_show_encrypted_field($values, $field, $entry_id){
global $frm_encrypted_fields;

if (in_array($field->id, $frm_encrypted_fields)){
$data = FrmEntryMeta::get_entry_meta($entry_id, $field->id);
//$data = $values['value'];
$values['value'] = Cryptor::Decrypt($data, SMRI_CRYPTOR_KEY);
$values['btsp']['prepend'] = '';
}

return $values;
}

hello, @Eddiemoto  How can I changed Encrypted values when Xml values Views any Actions There?

Discussion closed.