Home Forums Front-end Issues Get post data from form fill before post is saved


Get post data from form fill before post is saved

  • I feel like this should be possible but none of the hooks/actions/filters I’ve read about seem quite right for what I want. This is for an advanced search feature with a few conditional fields.

    I’m hoping for this general procedure:
    1. User fills out form
    2. User hits submit button
    3. The form gets validated
    4. If the validation succeeds, I save the post data (the data that wordpress would use to save a post to the database) to a variable
    5. The post does not get saved

    Normally I would just iterate through every field and grab the value from it, but I’ve noticed if a select2 field, for example, has a value, then, at some point during a form fill, the conditions to display it aren’t met, the value will persist in the element. On the contrary, if a post is submitted, any fields with their conditions not met will not be saved to the database.

    I’m hoping I can hook in at the point where the subset of data that will be saved in the database is determined, and use that data for a separate purpose rather than saving it as a post.

    If that’s not possible, are there any recommendations for grabbing that post data and deleting the post immediately after?

Viewing 1 post (of 1 total)

The topic ‘Get post data from form fill before post is saved’ is closed to new replies.