Jun 6th, 2010, 9:55 PM
Hi Aluwe,
Excellent points!
(1) First, I totally forgot to mention how to trigger the emails. When you use the API to submit your form contents, any email templates that have the "on submission" trigger set (on the first tab of the Edit Email Template page in Form Tools) will be sent on the final step of your form when the submission is actually finalized. This is the bit that looks like this:
However, in the case I described above, the submission is NOT finalized. So the email will never get sent! Ack!
Instead, add the following key to the $params hash:
That explicitly tells Form Tools to send the emails.
(2) Finalizing the submission
In the example above, I mentioned using ft_finalize_submission($form_id, $submission_id) function, but that will actually re-send the emails (I'll log this as a bug - the emails being sent should be configurable). So instead, replace that section of the code with the following:
(X will need to be the form ID). That should work fine.
Ah okay, sorry I wasn't clear! Basically, what you need to do is just follow the instructions for adding an API form. Once form submissions are being added properly, edit the form page BEFORE the final page. This page will have some code like this:
The important bit is the finalize => true bit. You don't want that any more! Just remove that line.
Hope this info helps... let me know if you have any more questions.
- Ben
Excellent points!
(1) First, I totally forgot to mention how to trigger the emails. When you use the API to submit your form contents, any email templates that have the "on submission" trigger set (on the first tab of the Edit Email Template page in Form Tools) will be sent on the final step of your form when the submission is actually finalized. This is the bit that looks like this:
PHP Code:
$params = array(
...
"finalize" => true
...
);
ft_api_process_form($param);
However, in the case I described above, the submission is NOT finalized. So the email will never get sent! Ack!
Instead, add the following key to the $params hash:
PHP Code:
$params = array(
...
"send_emails" => true
...
);
ft_api_process_form($param);
That explicitly tells Form Tools to send the emails.
(2) Finalizing the submission
In the example above, I mentioned using ft_finalize_submission($form_id, $submission_id) function, but that will actually re-send the emails (I'll log this as a bug - the emails being sent should be configurable). So instead, replace that section of the code with the following:
PHP Code:
$query = mysql_query("
UPDATE {$g_table_prefix}form_X
SET is_finalized = 'yes'
WHERE submission_id = $submission_id
");
(X will need to be the form ID). That should work fine.
Quote:In your example, I am not clear about this on your step 1 "Once the form is added, REMOVE that key-value pair. Now, all submissions will be added to the database but won't show up.".
Ah okay, sorry I wasn't clear! Basically, what you need to do is just follow the instructions for adding an API form. Once form submissions are being added properly, edit the form page BEFORE the final page. This page will have some code like this:
PHP Code:
$params = array(
...
"finalize" => true,
...
);
ft_api_process_form($params);
The important bit is the finalize => true bit. You don't want that any more! Just remove that line.
Hope this info helps... let me know if you have any more questions.
- Ben