Skip to content

Instantly share code, notes, and snippets.

@vfontjr
Last active May 5, 2020 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vfontjr/146c663e2c86c71d6cc653751b4164bc to your computer and use it in GitHub Desktop.
Save vfontjr/146c663e2c86c71d6cc653751b4164bc to your computer and use it in GitHub Desktop.
<?php
add_filter( 'frm_include_credit_card', '__return_true' );
<?php
function vmf_encrypt( $data ) {
$key = FORMIDABLE_SALT;
$method = FORMIDABLE_METHOD;
$options = FORMIDABLE_OPTIONS;
$iv = FORMIDABLE_IV;
return openssl_encrypt ( $data, $method, $key, $options, $iv);
}
function vmf_decrypt( $encrypted ) {
$key = FORMIDABLE_SALT;
$method = FORMIDABLE_METHOD;
$options = FORMIDABLE_OPTIONS;
$iv = FORMIDABLE_IV;
return openssl_decrypt ( $encrypted, $method, $key, $options, $iv);
}
<?php
define('FORMIDABLE_SALT', 'Si-+7^9Xtv5.vb`<T~F)wG?~,v76T [h%7N,h3/4=QVrW~&,QV|uXu63a(K$e.G^');
define('FORMIDABLE_METHOD', 'AES-256-CBC');
define('FORMIDABLE_OPTIONS', 0);
define('FORMIDABLE_IV', ';8qRaMk*jhFDYy3p');
<?php
add_filter('frmpro_fields_replace_shortcodes', 'decrypt_my_field_for_view', 10, 4);
function decrypt_my_field_for_view($replace_with, $tag, $atts, $field){
if(isset($atts['decrypt'])){
$encrypted = $replace_with;
$replace_with = vmf_decrypt($encrypted);
}
return $replace_with;
}
<?php
add_filter('frm_setup_edit_fields_vars', 'decrypt_my_field', 20, 3);
function decrypt_my_field($values, $field, $args){
if($field->id == 125){//Replace with the ID of your field
$encrypted = $values['value'];
$values['value'] = vmf_decrypt($encrypted);
}
return $values;
}
<?php
add_filter('frm_pre_create_entry', 'encrypt_my_field');
add_filter('frm_pre_update_entry', 'encrypt_my_field');
function encrypt_my_field($values){
if ( $values['form_id'] == 5 ) { //change 5 to your form id
$current_value = $values['item_meta'][25]; // change 25 to to id of your field
$encrypted_value = vmf_encrypt( $current_value );
// store the encrypted value to the DB
$values['item_meta'][25] = $encrypted_value;
}
return $values;
}
<?php
openssl_encrypt ( string $data , string $method , string $key [, int $options = 0 [, string $iv = "" [, string &$tag = NULL [, string $aad = "" [, int $tag_length = 16 ]]]]] )
openssl_decrypt ( string $data , string $method , string $key [, int $options = 0 [, string $iv = "" [, string $tag = "" [, string $aad = "" ]]]] )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment