Changing form data before save not working
-
Michael,
I’d been using your suggestions (http://cfdbplugin.com/?page_id=747) for modifying CF7 data before it is saved to the DB. It worked fine at first, but now it’s not working. I don’t know if it is a problem with my PHP code or, perhaps, something to do with the updates in WP and CF7 since I wrote the code in early January.
I have a form with two checkboxes that are optional. One is to flag a charge entry as a new client, the other is to attach a special services modifier. I have the code in your “Add Actions and Filters” plugin. Unfortunately, even when the checkboxes are left empty, the routine appends the flag/modifier to the respective columns (I do this to shrink the number of columns in a query display via shortcode, otherwise it overflows the page). Here’s the routine, perhaps you can see what I’m missing:
function chgFilter($formData) { $formName = 'Single Charge Submission'; $chgMod = ''; $flagNew = ''; if($formData && $formName == $formData->title) { //Consolidate the charges fields if(empty($formData->posted_data['Mod'])) { $chgMod = ''; } else { $chgMod = '–25'; } $formData->posted_data['Chg1'] = $formData->posted_data['Chg1'] . $chgMod . "\n\r" . $formData->posted_data['ProlSvc']; // //Flag new clients as part of ID number rather than in a separate column if(empty($formData->posted_data['NewCl'])) { $flagNew = ''; } else { $flagNew = 'NEW—'; } $formData->posted_data['ClNbr'] = $flagNew . $formData->posted_data['ClNbr']; } return $formData; // Return the data } add_filter('cfdb_form_data', 'chgFilter');I’ve tried using the
isset(foo)function and have also tried matching the POSTed data to the checkbox text “values” in theifstatements, but without success. I have also tried changing the form’s checkbox text “values” and trying to append that POSTed data to the other items (that results in “array” as a word being appended!). So, I’m lost on this. Any help would be greatly appreciated!https://ww.wp.xz.cn/plugins/contact-form-7-to-database-extension/
The topic ‘Changing form data before save not working’ is closed to new replies.