• I am using ContactForm7 & Contact Form DB plugin to contacts in database.

    In contact form 7 I used “|” (pipe) operator to send mail according to country in select option.

    But for to save country name in database, I used filter as;

    function location_form_handler_Opportunities_Contact($formData)
    {
    $formName = ‘Opportunities_Contact’; // change this to your form’s name
    $fieldName = ‘your-country’; // change this to your field’s name
    $newFieldName = $fieldName . ‘_email’;
    return form_with_pipes_handler($formName, $fieldName, $newFieldName, $formData);
    }

    add_filter(‘cfdb_form_data’, ‘location_form_handler_Opportunities_Contact’);

    I have some of email id’s for specific countries, and for remaining countries I used one email id as e.g: [email protected]

    My problem is save country name(_raw_your-country) as well in database I used above filter & it working perfectly for specific email id, but it is not working for common email id (that is your-country value is not correct, it takes first value in option with name of the county having common email id.) Therefore in database the first country name is saving instead of respective country associated with email id.

    Please help to resolve this issue.

    https://www.ads-software.com/plugins/contact-form-7-to-database-extension/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    It’s hard for me to comment without seeing your entire example. Ensure that your CF7 definition has pipe values for each of the choices in your select field.

    You can try debugging by writing some values to a file inside the form_with_pipes_handler function. The code example is just pulling the information out of CF7. So you might double-check what CF7 is returning for $formData->WPCF7_ContactForm->form_scan_shortcode()

    Thread Starter Suresh Shinde

    (@suresh-shinde)

    Thank you Sir I will try

    Thread Starter Suresh Shinde

    (@suresh-shinde)

    Sir, Contact Form7 working properly (After submitting form in email data is correct).

    The issue is data saving in database by Contact Form DB plugin. Also its working but when the value(email id) after pipe is different for all select options.

    The problem is when the value after pipe (in this case email id) is same for some select option. Then it takes first value of country name in select option to save in database instead of respective associated value.

    Plugin Author Michael Simpson

    (@msimpson)

    Unfortunately all the emails after the | have to be unique.
    Please see: https://www.ads-software.com/support/topic/cf7-menus-with-pipes-and-repeated-emails?replies=2#post-8046897

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Changing Form Data Before it is Saved with ContactForm7’ is closed to new replies.