Skip to content

Instantly share code, notes, and snippets.

@mtruitt
Last active October 15, 2019 14:44
Show Gist options
  • Select an option

  • Save mtruitt/4ee99d4080604c76ca0c6546c4ba25ca to your computer and use it in GitHub Desktop.

Select an option

Save mtruitt/4ee99d4080604c76ca0c6546c4ba25ca to your computer and use it in GitHub Desktop.
Used to strip CC/Bank information from a Formidable form error where it was getting stored.
<?php
add_action('wp_head' , 'remove_cc_information');
function remove_cc_information() {
global $wpdb;
$db_table_name = $wpdb->prefix . 'frm_item_metas';
$results = $wpdb->get_results("SELECT id, meta_value FROM {$db_table_name} WHERE field_id = '83'", ARRAY_A);
// Loops through and unserializes data to strip out CC/CVC numbers then updates the DB
foreach ( $results as $result) {
$id = $result['id'];
$meta_data = unserialize( $result['meta_value']);;
$cc = $meta_data['cc'];
if( $meta_data['cvc'] !== '') {
$meta_data['cvc'] = '';
}
$cc = str_repeat('X', strlen($cc) - 4) . substr($cc, -4);
$meta_data['cc'] = $cc;
$re_serialized_data = serialize($meta_data);
$wpdb->update($db_table_name, array( 'meta_value' => $re_serialized_data), array( 'id' => $id));
}
// Remove Routing number
$wpdb->update($db_table_name, array( 'meta_value' => ''), array( 'field_id' => '84'));
// Remove Account number
$wpdb->update($db_table_name, array( 'meta_value' => ''), array( 'field_id' => '85'));
echo 'Complete';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment