I am storing sensitive data in a CPT using ACF fields. Each sensitive field is encrypted upon form submission before inserting to the DB – text converted to something like ‘M3QxKzRXN1FaVlg3alZaUDlNbHdOdXVuSnZQNUF5U29XVWpVKzNPSGFFRT0’
I can decrypt that to show on the front end, but that is not what I want to achieve.
I want the fields in the WP backend to decrypt the field data before outputting it in the post editor, so that the admin can see actual data.
E.g. instead of
Name: jsdfhJHjhdfsjhgdsf
Address: yutsefdSADfuy23eufj&A
I want the admin to see (this will never be accessible on the frontend – backend only):
Name: John Doe
Address: 123 California Road
Any help is much appreciated.
Encrypt on acf/update_value
Decrypt on acf/load_value only when is_admin() is true