Currently, the post status of a post generated from a Gravity Form submission is set via the Post Title, Post Body or Post Excerpt fields. So what do you do if you want the post status to be based on some form of user input? It’s a form-specific option (as opposed to field specific) which means Gravity Forms’ powerful conditional logic can not help us here.
Fortunately, the solution is quite simple. Put on your pointy wizard hats and check out this snippet.
How do I install this snippet?
Use a simple copy and paste spell to copy the snippet above and paste it in your theme’s functions.php file.
Do I need to modify the snippet to work for my form?
Yes. There are comments inline in the code which indicate where you’ll need to make modifications.
- Update the
123in the filter name
gform_post_data_123to the ID of your own form.
- Update the
4in both places you see
$entryto your field ID.
This snippet assumes the value of the specified field will be a valid post status. Here is an example of how this can be configured using a drop down field:
Is it possible to set the post status based on the option label or a value that is not a standard post status?
Is Gravity Forms made of magic? Yes and yes! The snippet to accomplish this is only slightly more involved. I’ve added this as a separate post here: Set Post Status by Field Value (Advanced)
This is the simplest method to accomplish this functionality. Make sure you check out the advanced version too!