Set Post Status by Field Value

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.

  1. Update the 123 in the filter name gform_post_data_123 to the ID of your own form.
  2. Update the 4 in both places you see $entry[4] to 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:

Drop down field used to set post status


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!


  1. Josh
    Josh July 29, 2015 at 5:26 am

    Thanks for the post, David.

    Would it be possible to create three separate Gravity forms with the same function?

    I wrote the same snippet three times on function.php, and replaced the form ID (gform_post_data_n) and field ID ($entry[n]) in each to correspond to the respective Gravity form. A refresh on the website returns a blank white page.


Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Download Snippet

Set Post Status by Field Value

This field is for validation purposes and should be left unchanged.