1

Is there a way to prevent a webform submission to be saved in the database?

I have added a custom submit handler to my webform but I don't want to save in the DB but send it to an external webservice.

function MY_MODULE_form_alter(&$form, $form_state, $form_id)  {

    if ($form_id == "MY_WEBFORM_ID")  {         
        $form['#submit'][] = "_MY_MODULE_webform_handler";
    }

}

function _MY_MODULE_webform_handler($form, &$form_state) {
    // How do I stop data being saved in DB?
}

How do I do that? Thanks!

3

There is a module that's compatible with the 7.x-3.x branch that gives you the option to do just that:

This module adds the ability to choose whether a webform should be saved to database or not. Within settings of each webform you can choose the option.

There is also a related issue in Webform's queue that is tracking the progress of getting the functionality into the webform module.

If you don't want to use the sandbox module, I'm sure you could check out the source and see what they're doing differently from what you have posted above.

  • Basically, once the submission is saved they remove it from the db. Fair enough :) – Teknotica May 21 '14 at 15:58
  • 1
    There is a better, more complete answer to this question. As @Teknotica pointed out, the sandbox module deletes the submission after the fact, which doesn't seem like a good solution. And according to an issue in the queue, it doesn't even do that correctly (doesn't use webform_submission_delete() which means remnants could be left over). I'll try to post a more complete answer that summarizes the discussion in 290448 when I get a chance. Or someone else should feel free to do the same. – Adam Balsam May 21 '14 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.