PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Purposefully not save form in entries database

  1. sccr410
    Member

    Is there a way to not save the submitted form data into the Entries database? We are using forms to allow users to submit content (a new post into a Custom Post Type). We are expecting hundreds of entries a day based on the existing version of the website. I want to keep the database size down as much as possible.

    Posted 13 years ago on Friday January 7, 2011 | Permalink
  2. [UPDATED CODE February 25, 2013 to use gform_after_submission rather gform_post_submission]

    Hi Sccr410,

    Try adding this code to your functions.php file:

    http://pastebin.com/7eqFGYyR

    You'll want to update the 1 following "gform_after_submission_" on this line:

    add_action('gform_after_submission_1', 'remove_form_entry', 10, 2);

    ...to the ID of the form you wish to "not save" the entries for. Since there is no way to not save the entries, what this script does is simply deletes them after the post has been submitted.

    Posted 13 years ago on Friday January 7, 2011 | Permalink
  3. sccr410
    Member

    Perfect, thank you!

    Posted 13 years ago on Friday January 7, 2011 | Permalink
  4. RichardBest
    Member

    This is awesome, thanks David. I didn't know this could be done automatically like this. I'll be implementing it too as there's no real need, in my use case, for a separate GF table entry if the post is already in the database.

    Cheers
    Richard

    Posted 13 years ago on Friday January 7, 2011 | Permalink
  5. My pleasure! Glad I could help. :)

    Posted 13 years ago on Friday January 7, 2011 | Permalink
  6. Hi,
    I have a few questions about this:

    1. Which functions.php page are you referring to? I've found two so far - one in my theme directory and one in the "wp-includes" directory. But I did a search and neither contains the code "add_action('gform_post_submission_1', 'remove_form_entry', 10, 2);".

    2. I need to auto-delete several different forms from the site when they are emailed. Is that possible? If so, could you give an example of how it would look? I assume there would be the first form ID, then some type of separator (comma?) then the next and so on?

    Thanks in advance for your help :-)
    Suze

    Posted 13 years ago on Friday March 25, 2011 | Permalink
  7. 1. He is referring to your themes functions.php which is where customizations would go. The one in the main theme directory which is the one WordPress looks for first.

    2. If you want to do this for multiple forms you'd have to duplicate the code and do the same code multiple times changing the _1 in gform_post_submission_1 to the form id you want the code to execute on.

    Posted 13 years ago on Friday March 25, 2011 | Permalink
  8. Hi Carl,

    Thanks. I copied and pasted the code into the bottom of my functions.php (I'm using an Artisteer theme). However, when I now try to access the form in the WP admin panel for Gravity Forms, I get the following error message:
    "Parse error: syntax error, unexpected '<' in /.../functions.php on line 374"

    Line 374 is the first line of the code from pastie - <?php

    Here's a little of the code above what I copied and pasted in - maybe you can see from this what I'm doing wrong?

    http://pastie.org/1733043

    Posted 13 years ago on Sunday March 27, 2011 | Permalink
  9. We would need to see your entire functions.php file to see what is going on. If you can email me it at carl@rocketgenius.com I can take a look and see what is going on.

    Posted 13 years ago on Sunday March 27, 2011 | Permalink
  10. 61pixels
    Member

    Actually this is really easy, you simply added your own call to PHP when it wasn't necessary. Simply remove it and all will be fine. So at this part in your functions (line 7-10 in your above code):

    </div>
    <?php
    }
    <?php

    To simply this:

    </div>
    <?php
    }
    Posted 13 years ago on Tuesday March 29, 2011 | Permalink
  11. Thank you Carl and 61 Pixels!

    Sorry for the delayed reply - I didn't get the email notification that there were replies and am juggling too many things now that I forgot to check.

    In any event, 61 - you nailed it! Thanks so much. Problem solved :-)

    Posted 13 years ago on Tuesday April 12, 2011 | Permalink

This topic has been resolved and has been closed to new replies.