Use Gravity Forms to Create User-Submitted Posts

The concept is pretty simple. Using Gravity Forms “Post Fields” you can create a form which generates a post when it is submitted. All you have to do is add the desired post fields to your form. When the form is submitted, Gravity Forms will check if any post fields exist on the form and if so, generate a fresh new post based on those post fields!

Before we get too much further into this, I’d really recommend checking out the basic Gravity Forms post creation demo. If you’re new to Gravity Forms this will give you a better idea of what to expect and some context for the rest of this tutorial.

Gravity Forms Post Features

This tutorial will cover each Post Field and some of the cool features each field has to offer. Here is a quick list of post-related functionality Gravity Forms can handle right out of the box:

  1. Set the Post Title
  2. Set the Post Body/Content
  3. Set the Post Excerpt
  4. Set the Post Category (GF v1.6.3 adds support for setting multiple categories!)
  5. Set Post Tags
  6. Upload Images to the Post Gallery
  7. Set the Featured Image (aka, “Post Thumbnail”)
  8. Create custom fields for the post
  9. Set the default Post Status (“Draft”, “Pending Review” or “Published”)
  10. Set the default Post Author
  11. Set the default Post Format (ie “Standard”, “Link”, “Gallery”, “Quote”, etc)

Not bad, huh? You can use this list to get more information on features that interest you OR if your thirst for Gravity Forms knowledge is simply unquenchable, I suggest reading from top to bottom.

One thing Gravity Forms does not currently support is creating custom post types; however, there is a handy dandy third-party Gravity Forms add-on that allows you to create posts for custom post types with Gravity Forms available for free in the WordPress.org repository. It’s called Gravity Forms + Custom Post Types.

1. Setting the Post Title

Adding a Post Title field to your form will allow the user submitting the form to specify the title of the post. The Post Title field is also where you will manage the default Post Status, Post Author and Post Format of the created post. We’ll go into each of those in more detail later.

It is important to note that you can actually set the default Post Status, Post Author, Post Format from the Post Body and Post Excerpt fields as well. Be aware that these settings are all “linked” and changing one setting (the Post Status, for example) on one field will update the setting on all fields. Think of them as “form settings” managed on a field level.

One of the really neat features of the Post Title field is the ability to specify a “content template”. Enabling this option will allow you to use merge tags to populate the title with dynamic values. When might you want to do this? How about if you have a Post Category field on your form. When submitted, you want to append that selected category name before the submitted post title. Here’s how that might look:

Post Title Content Template Setting

2. Setting the Post Body/Content

Adding a Post Body field to your form will allow the user submitting the form to specify the content of the post. Like the Post Title field, this field also provides options for managing the default Post Status, Post Author and Post Format of the created post.

Also like the Post Title field, the Post Body field provides the option to create a content template. It is with the Post Body field that the content template can really shine! The most obvious (and arguably the most useful) benefit is being able to insert submitted Post Images along side the submitted post content. I’ve implemented this functionality in the demo here. Here is the actual configuration I’m using to achieve the effect:

Post Body Content Template Setting

You’ll notice I’m using a pretty fancy merge tag to display the medium sized featured image to the right of the post content. Don’t worry! You don’t have to learn all that merge tag syntax. When you select a Post Image field from the merge tag drop down, a new drop down will appear with a full list of size and alignment options!

Post Image Merge Tag Options

3. Setting the Post Excerpt

Adding a Post Excerpt field to your form will allow the user submitting the form to specify the excerpt content. Like the Post Title and Post Body fields, you will be able to specify the Post Status and Post Author from this field.

4. Setting the Post Category

Adding a Post Category field to your form will allow the user submitting the form to specify which category their post should be filed in. The Post Category field not only allows you to specify which categories should be available in the field, it also provides an option to display the field as one of the following field types: Drop Down, Checkboxes, Radio Buttons, and Multi Select. Selecting “Checkboxes” or “Multi Select” will allow users to select multiple categories to file their post in! This is relatively new functionality available in GF v1.6.3.

Post Category Field Settings

Feel free to add multiple Post Category fields on the same form. Categories from different Post Category fields will be consolidated and applied when the post is created.

5. Setting the Post Tags

Adding a Post Tags field to your form will allow the user submitting the form to specify how their post should be tagged. Tagging is a good way to specify organizable key words and subjects that the post relates to. The Post Tags field provides the option to specify which field type the field should display as. Available field types are: Single Line Text, Drop Down, Multi Select, Checkboxes, and Radio Buttons. If using the “Single Line Text” field type, note that the expected format is a comma-delimited list of tags.

6. Uploading Images to the Post Gallery

Adding a Post Image field to your form will allow the user submitting the form to upload an image to the post gallery. You can include uploaded Post Images in the post content using the “content template” functionality. See the Post Body section above for more details.

The Post Image field also provides options for collecting image meta data. Checking any of the image meta data options will add an additional input to the Post Image field which can be filled in by the submitting user. This data is then stored with the Post Image.

7. Setting the Featured Image

You can specify a particular Post Image field to also be set as the Featured Image (aka Post Thumbnail) of the created post. Just select the “Set as Featured Image” option and Gravity Forms will work it’s magic when the post is created.

Post Image: Setting Featured Image

8. Creating Custom Fields

Adding a Post Custom Field will allow the user submitting the form to enter a value which will be stored in a custom field as part of the created post. Custom fields are a simple way to bind related data to a post. Here’s a real example of how the settings might be configured:

Post Custom Field Settings

With the above configuration in mind, imagine that you’re accepting user-submitted events for a blog about your night life. The data and time of the event will be pretty important. Custom fields to the rescue! With Gravity Forms’ Post Custom Field, you can specify a custom field to which the field value (in this case, the date of the event) should be mapped.

The Post Custom Field can use a variety of different field types including all Standard Field types and most Advanced Field types. This flexible field will allow you to capture a wide range of values include regular text, dates, times, phone numbers, URLs, files and more!

It is important to note that Gravity Forms does not handle displaying the custom field data (unless you’re using a content template!); however, there are plenty of tutorials available for modifying what content is displayed with your posts including displaying custom fields! For more information, see the Custom Fields documentation on WordPress.org.

9. Setting the Default Post Status

You can specify the default Post Status from the Post Title, Post Body and Post Excerpt fields. The available options are “Draft”, “Pending Review” or “Published”. A “draft” is a post that is not yet ready to be published. A post which is “Pending Review” is ready to be published pending a review by an administrator. A “published” post is live and viewable by visitors on your website.

Gravity Forms may not support it out of the box, but it’s actually quite easy to set the post status by a user-submitted field value. Here are two handy resources that demonstrate how!

  1. Set Post Status by Field Value
  2. Set Post Status by Field Value (Advanced)

10. Setting the Post Author

Like the Post Status, the default Post Author can be set from the Post Title, Post Body and Post Excerpt fields. You must select a user from the “Default Post Author” drop down; however, if you wish to assign the post author based on the logged in user submitting the form, just check the “User logged in user as author” option. Bare in mind, this option will only work if the user is logged in when submitting the form. Otherwise, the post author will default to the user selected in the drop down.

11. Set the Default Post Format

If you’re running a theme that supports Post Formats or if you’re using implementing them on your own theme, you’ll be happy to hear that Gravity Forms provides support for Post Formats out of the box. The Post Format can be specified on the Post Title and Post Body fields. All standard WordPress Post Formats are supported.

If you’d like some more information on post formats, I’d recommend checking out this walk-through.

Summary

That’s a fairly exhaustive overview of the post creation functionality. As you can see, Gravity Forms post creation functionality is very flexible and super powerful! If you have any questions, please share them with us in the comments.

Comments

  1. Victor says

    Hi, your site is great and I wonder if you or some one else can help with a idea.

    I want to get the answer of a form (some of then only will be displayed depending to some conditions) insert then into a editable box witch will be publish as a post.

    Ok, the form is done and its last page has a body post field in witch I insert (as default value) the basic text os the post with a lot of merge fields.

    The problem is the formatting and style. It would be great to insert html blocks in the post body edit field, but I can not do it, and using normal text fields I have problems with the final formatting.

    Does anyone have any idea who can help me?

    • Victor says

      Yes, I try, but using the default value its better for me, cause I can edit the text before send the form.

      Anyway, the problem is the formating of the merge fields.

      For example, I want to make a paragraph quoting the name of all products chosen in the form, but I have problems with the break line.

      Ex: {productA:1} {productB:2} {productC:3}

      One of the thing that I want is that if the protuct B was not chosen the result show this:

      {productA:1} {productC:3}

      And not this:

      {productA:1} <— blank space {productC:3}

      Do you know how to make it?

  2. Assal0le says

    Can Custom Post Field act like Post Image like what you explain in: 6. Uploading Images to the Post Gallery

    What do I mean is that: Can the user, upload images using Custom Post Field(as multiple file upload type), then show all images uploaded as a gallery in that Post?

    Please help us?

    Thanks, Best Regards, Assalole

  3. Chris says

    I have a specific case where I want the title of the post to include the name and optional company. The problem is that while the name is required, the company is not. So to Create a content template with the merge tags:

    {name:1} {company:2}

    How would I conditionally add a comma in between these ONLY if a company has been filled out?

  4. says

    This was a really great tutorial David! Perhaps you can solve a problem I’m having trouble getting an answer for.

    I’m building a site based solely on user-generated content, and I would prefer to eliminate the registration process, so I created a GF submission form, and tested it out. Everything seems to work exceptionally well, except for the “user-author-link” in the entry meta. What I’m trying to do is have the user’s website (if one is provided) linked to the author name, rather than the author page, but I simply can’t find any resource which touches on this topic.

    I’m more of an “idea” person, and not a coder but I am able to do the basics and was able to find the author-link in the functions, but can’t figure out how to get the GF website field to link to that line, so if you have any ideas in layman’s terms, I’d be forever grateful!

    • says

      If the author is not an actual “user” on the site, you may need to modify your page template to pull the author website from wherever you’re storing it. If it sounds like I’m not understanding your setup, please do clarify. :)

  5. says

    Hi David,

    I am developing a property developer website and i want to have a simple property booking form which allow user to book the apartment there by just entering few basic information such as name, email phone and apartment no. listed as dropdown list. Once the selected apartment no. is booked it should become disable for further booking unless site admin enable it. Also on the admin side i want site admin to approve and reject the booking which will basically disable or enable the apartment no in the dropdown.

    I tried many time but not able to find any solution also new to GF. Your prompt response is highly appreciated.

    You can visit following http://ibtikarrealestate.com/our-projects/ongoing-projects/project-1/ check for reservation list.

  6. Anne P says

    Hi David!

    Thanks for this tutorial, it’s very helpful. How would I add a link to the newly created post in the User notification email and/or the form confirmation?

    Thanks! Anne

  7. says

    Hi, thanks for this tutorial, I’v learned a lot. Can you cover how to add the Link to the Post in the confirmation / notification message please? Thanks!

  8. S Kaul says

    Hi David,

    Is there a way for a Dropdown Field to be dynamically populated by a specific Woocommerce Product Attribute? GF+CPT used to do this for me, but since it’s abandoned there is no other way to do it. Any ideas?

  9. Zack says

    Hey, David. Awesome article, again!

    I’m creating a form where logged in users can post, but I need them to be able to choose the author from a list. I know I can add a dropdown menu that lists all the authors on the site on a form, but how to do I attribute that value to the post’s author field?

  10. says

    Hi David, Any way to connect a date field to be the “publish date” for a post?

    I’ve setup and have a mostly working GForm that takes article submissions for a school weekly bulletin. It maps the categories and I’ve used 2 plugins to get a WYSIWYG post body and ‘Media’ button for uploads working, along with the plugin you have mentioned in the comments “Gravity Forms: Post Updates”.

    The final part is getting the submissions to be scheduled for a specific date, I’ve just started looking into how to do this and thought I’d drop you comment in case you had come across this idea?

    I also have a fall back to create a tagging setup for term and week then have the editor update the blog each Monday to the correct week and term tags only.

    Also <3 GWiz, Thanks!

Trackbacks

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>