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

    (@msimpson)

    These are all be listed in the database under their different form names, but when retrieving information in a short code, you can get data from multiple forms as once as if they were just one form.

    You can set form="*" to get information from all forms or list the form names using form="form1,form2,form3 in a short code.

    But if you really want to make the data all go into the same form name, follow the directions on changing data before it is saved wherein you can intercept the form submissions and change their form name.

    function change_title($formData) {
        if ($formData && in_array($formData->title, array('form1', 'form2', 'form3')) {
           $formData->title = 'THE CONSOLIDATED FORM NAME YOU WANT";
        }
        return $formData;
    }
    
    add_filter('cfdb_form_data', 'change_title');
    Thread Starter willbell

    (@willbell)

    Thank you for this, it’s going the right direction I think. But I am so lame at coding that I don’t know how to create a database and I don’t know how to write the code that would send the data from the seven forms to that database.

    Any help is appreciated.
    Thank you.

    Plugin Author Michael Simpson

    (@msimpson)

    I’m giving you the code. You just have to fill in some blanks. I’ll make it simpler below. Use Add Actions and Filters plugin to put in the code.

    function change_title($formData) {
       // change this: Pick a name. Any name not already used by a form
        $myUnifiedForm = 'THE CONSOLIDATED FORM NAME YOU WANT'; 
    
       // change this: list all the forms you want to consolidate. Replace FORM1 with the name of a form, etc. Add as many as you want. put commas between and use single quotes.
        $myForms = array('FORM1', 'FORM2', 'FORM3'); 
    
        if ($formData && in_array($formData->title, $myForms) {
           $formData->title = $myUnifiedForm;
        }
        return $formData;
    }
    
    add_filter('cfdb_form_data', 'change_title');
    Thread Starter willbell

    (@willbell)

    Thank you Michael, I can now see how the structure works.

    Thread Starter willbell

    (@willbell)

    Michael,

    I got this error code above the box where the code goes –

    Parse error: syntax error, unexpected ‘{‘ in /home/anasysin/public_html/wp-content/plugins/add-actions-and-filters/AddActionsAndFilters_Plugin.php(114) : eval()’d code on line 2

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/anasysin/public_html/wp-content/plugins/add-actions-and-filters/AddActionsAndFilters_Plugin.php(114) : eval()’d code:2) in /home/anasysin/public_html/wp-content/plugins/constant-contact-api/functions.php on line 5

    Here is the code I put in;
    function change_title($formData) {
    if ($formData && in_array($formData->title, array(‘Brochure Data Download AFM+’, ‘Brochure Data Download IR’, ‘Brochure Data Download IR2’, ‘Brochure Data Download nanoTA’, ‘Brochure Data Download Probes’, ‘Brochure Data Download SThM’)) {
    $formData->title = ‘Combined Brochure Forms’;
    }
    return $formData;
    }

    add_filter(‘cfdb_form_data’, ‘change_title’);

    Plugin Author Michael Simpson

    (@msimpson)

    You’re missing a close-paren at the end of the if-statement. Try:

    function change_title($formData) {
        if ($formData && in_array($formData->title,
                        array('Brochure Data Download AFM+',
                                'Brochure Data Download IR',
                                'Brochure Data Download IR2',
                                'Brochure Data Download nanoTA',
                                'Brochure Data Download Probes',
                                'Brochure Data Download SThM'))) {
            $formData->title = 'Combined Brochure Forms';
        }
        return $formData;
    }
    
    add_filter('cfdb_form_data', 'change_title');
    Thread Starter willbell

    (@willbell)

    That worked, no error messages, thank you.

    Another question. I put this code in the “Add Actions and Filters” tool and saved. When I go to Contact DB though, I don’t see it. Is there a step I missed?

    Thank you,
    Will

    Plugin Author Michael Simpson

    (@msimpson)

    This applies to new submissions coming in.

    Hello~
    I thank you for your great plugin and your kind guide.

    I tried to modify my plug in as your guide.
    Combied DB was published, but there are another 5 db for each 6 form, also published

    I combied from form1 to form 6 and I want to use just new one.
    I don’t need each form db, How can it be deleted when combined DB is published.

    Below is my code which is added using ‘Add Actions And Filter’

    ——————Below————————–

    function change_title($formData) {
    if ($formData && in_array($formData->title,
    array(‘Medical Record Check’,
    ‘Medical Record Check 2’,
    ‘Medical Record Check 3’,
    ‘Medical Record Check 4’,
    ‘Medical Record Check 5’,
    ‘Medical Record Check 6’))) {
    $formData->title = ‘Combined Medical Record Forms’;
    }
    return $formData;
    }

    add_filter(‘cfdb_form_data’, ‘change_title’);

    Plugin Author Michael Simpson

    (@msimpson)

    It is not clear to me what your question is. Is it about deleting something?

    Thread Starter willbell

    (@willbell)

    Michael,

    I put the code (above) to the Add Actions and Filters plugin, then tested one of the contact forms, but the data did not read to a “Combined Brochure Forms” DB. When I go to “Contact DB” I don’t see Combined Brochure Forms listed in the pull down window. I did create a contact form called “Combined Brochure Forms” thinking that this would help initiate the DB, but it still doesn’t work. I’m stumped.

    Any Help would be appreciated. Here’s some screen captures – https://www.anasysinstruments.com/combined-brochure-databases/

    Thank you,
    Will

    Plugin Author Michael Simpson

    (@msimpson)

    @willbell
    Creating a “Combined Brochure Forms” form definition is irrelevant and unnecessary.

    Everything looks right in the screenshot that you show. I just set up my own example and it works…

    I see your code doesn’t have the same line breaks as what I posted above. Shouldn’t matter, but copy-paste my code, save and try a submission.

    Thread Starter willbell

    (@willbell)

    I did as you suggested, tested and still no “Combined Brochure Forms” database. The data did show up in “Brochure Data Download AFM+”. If I have the code correct, is there something else with the setup that I could be missing? Does it matter that I’m running WP 3.6.1? Sorry to bother you so much but we’re so close and this is pretty important for me.
    Thank you.

    Plugin Author Michael Simpson

    (@msimpson)

    Are you sure there are no extra spaces at the beginning or end of the form names?

    Thread Starter willbell

    (@willbell)

    Checked, same.

    Here’s another thought. In the “Additional Settings” box for each of the forms I have this code:

    on_sent_ok: “location = ‘https://www.anasysinstruments.com/afm+_Brochure.pdf’;”

    Could this be causing a problem?

    Thank you,
    Will

Viewing 15 replies - 1 through 15 (of 44 total)
  • The topic ‘Multiple forms submit to one database’ is closed to new replies.