Last active
October 15, 2019 14:44
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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