[cfdb-save-form-post]

October 18th, 2014

AVAILABLE AS OF RELEASE 2.1

WARNING: Only use this short code to capture data from a form that is NOT created by Contact Form 7 (CF7), Fast Secure Contact Form (FSCF) or JetPack form. If you are using one of those, then this plugin will automatically capture the form submissions. This short code is for special cases.

This plugin was written to capture data from Contact Form 7 (CF7), Fast Secure Contact Form (FSCF) and JetPack forms but what if you don’t want to use them? What if you want to put an old-fashion HTML FORM tag in your post or page and have it submit to a post or page where the data will be put in the database? You may want to do this if you are trying to do some fancy things on the form’s target page that you just can’t do with CF7 or FSCF.

In that case you can use this shortcode on the page that a form posts to to make it save the submission data to the database. This short code does not generate any output on the page where it is placed.

Hi, this plug in is great! However, I am afraid I will have to learn php anyhow…
I have a FSCF form. When i submit the form to the db I also wan to calculate the total (add all the answers) and store the sum in the db.
I have bought the extension and created a new column in the db. What is the easiest way to store the sum?
Thanks!

Storing the sum is difficult because the plugin doesn’t support automatically adding additional fields to a form submission. However, it is a lot easier to create a custom short code that would display form data and add the sum. In that case the sum is not stored in the DB, but is generated each time the short code executes to display data on a web page that you create. A similar and much easier solution is to do an Excel IQuery export. In this case, you could set up an Excel spreadsheet that automatically updates with the latest data, and add your own column doing whatever summation you like. Consider whether these kinds of approaches would be adequate for your needs.

I have the plugin installed, but the form is within a custom template that does not include most of the wordpress headers/footers. So is there a way to add this functionality without a shortcode? direct php?

I do not get any records written to the database. I intend to use this facility to capture jetpack subscription info.
For testing purposes, I have set up a (private) post containing the following. It appears as if it is working, but nothing is written to the database.

UNFORTUNATELY MY HTML HAS BEEN SWALLOWED !! I will need to resubmit when I find out how to escape the html
message:
[cfdb-save-form-post]

This was not designed to work with JetPack subscriptions. I don’t if you are trying to capture the event where a user subscribes or what. And I don’t know if such an event results in a form post to a content page (which could conceivably be captured but I’d be surprised if it worked that way) or some over interaction with the server that cannot be captured.

I do not understand what you mean by “swallowed” html. If you put a short code on a page, you might need to first switch to the post editor to “Text” instead of “Visual” to put in html and short codes so they are not escaped.

I am trying to capture the event whereby a user uses a jetpack widget to subscribe in order to follow a blog. I couldnt get this to work using your plugin/shortcode, so I tried using different html (unrelated to jetpack) to ascertain whether the fault lay with the way I was trying to use your plugin/shortcode. I tried to include this html in my earlier post but the html was swallowed by the code which makes this forum work. I think this is because I did not use backticks. I have tried again to include this html as below (but this time with backticks).

Assuming the html below does display itself in the , can you please guide me as to why it does not result in any data being added to the database.
`

I am trying to save custom form data with dynamically added rows. The form initally has one row (with 5 text inputs) but users can add rows (using jQuery) as needed. I can get this to work by incrementing the input names (e.g. inputa1, inputb1, … inpute1 –> inputa2, inputb2, … inpute2) however, as expected, this adds additional columns to the datatable in the backend. I would like for each additional row to save the data under the same column heading as the first row. How could this be accomplished? By the way, thanks for the great plugin!

When a form is submitted it comes as a set of field-name/field-value pairs. The plugin just dumps those in the DB as column name & values. So you should have your JavaScript name new dynamic fields to be the column names you want. If you want to change the column names on the back end, refer to the page on this site about changing data before it is saved. link

@Michael Simpson
But if I name the newly added field with the same name as the input on the first row, the plugin only saves the last input with that name. For example, if I have Row1 and Row 2 , then only the Row 2 input value gets saved.

@Aaron
Sorry. some of my comment was modified because I put pseudocode in…
But if I name the newly added field with the same name as the input on the first row, the plugin only saves the last input with that name. For example, if I have Row1 with input named “field1″ and Row 2 with input named “field1″, then only the Row 2 input value gets saved.

@Aaron
The browser can only submit one value for each field name. So if you have two fields in your form both named “field1″, then the browser will pick one and submit that. Seems like your browser picks the last one. This is a limitation of HTTP, not the browser or the plugin.

@Michael Simpson
Thanks for your quick responses. I was finally able to get this to work by having the users dynamically add new forms, rather than rows, and submitting those forms in a loop via Ajax. I’m not sure if it is the best way to do things, but it works.

Just a note that your instructions on this page have one mistake in them. Part of the way down it says the shortcode is [cfdb-save-post-post]. Which obviously should be [cfdb-save-form-post] like the title. I was hyper-focused enough to copy and paste the wrong shortcode and wonder why it didn’t work. So someone else might be. lol.

Thanks for the plug-in it works great, as advertised. I am using it with Visual Form Builder.

Hello
First, please excuse for my bad english: I’m french.
I was using CF7 but that was before I now use an new WordPress theme: Enfold that came with it’s own forms.
So i tried the [cfdb-save-form-post] in a page where I have a Enfold form ans yes it’s works but when I look at the data, some characters are not displayed nicely, eg:
a email adresse look like this: name%40mydomain.com
Spaces are: %20
A [ is: %5B
A ] is: %5B
and so on…

Those encodings (such as %20 for space) are how special characters are encoded in URLs. I supposed that your form plugin is encoding the information submitted with the form but not decoding it. CFDB is then picking up the encoded values.

You could add a filter to try to correct the data. I think this code will fix it:

Thank you fot this code but it do not work, nervermind I have modified the enconding of my theme post ajax form.

So the shortcode [cfdb-save-form-post] works very well inside a page but I have many Forms that are not specially in a page.
Is there a way to use this shortcode on the whole site? That way it will trigger any forms tat are posts

I tried both options and none of them worked. No records where added to the database.
I dont have any form plugins so my Contact DB Settings are all set to false on the “Capture form submissions from …”
The form I’m trying to retrieve data from was already created. Is there something different that I need to setup to get this form to retrieve the data?
Thanks!

@lw2014
In your method, variable $cf_data is not defined. I think it is supposed to be the $fdata in your case.
And I would set $title to a default value right before the “foreach” in case it doesn’t get set in the “else” clause.