Use Gravity Forms to Create User-Submitted Posts

view demo

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. Matthew says

    Have a question relating to the options described. How would I use a form to create a posting but for a Q and A section. It would collect on the back end once the forms answer line is filed out could be auto posted our with click. Also the form with the question and answer would get email to the submitting party when posted. Any help would be great. Thanks

    • David Smith says

      Hey Matthew, I’m not sure I understand your scenario. The form would contain several questions and the user would provide answers or each form would be a question from the user which you would answer?

    • Matthew says

      My form wouldbe a single form. The form fields would be name, email, question, and answer. The form would show on front end every field but the answer field. The answer field would only show on the back end. Once the answer field is filed in from the back end the form would post to add custom post type and email a copy to the user that submitted the question.

    • David Smith says

      My recommendation would be to create the post based on the question. Rather than answer the question via the entry editor, I would answer the question in the generated post. You can set the post as draft by default and one you’ve answered the question (in the post editor) and then publish the question (and answer) as a single post.

  2. says

    Hi David,

    I was just wondering if there was a way to integrate these front end posts to user profiles in buddypress by including a tab that directs them to a list of their posts?

    Thanks for your response!

  3. dugue says

    Hi, Thanks for the demo. I understand it for adding 1 picture but what if i need the user to be able to add as many pictures he wants? your demo seems to work only for 1 picture added to the post body… Also, do you if it is possible to add links and video on the post body…. thanks

  4. Kim says

    I want to achieve the same effect you did on your post creation demo: a page that generates a link to the post created. Obviously I would set the post to ‘published’ in Gravity Forms instead of ‘pending review’ or ‘draft’. But how would I get the link? Can that be set dynamically in GF?

    Thanks!

  5. Kim says

    Great post! The plugin you referenced for creating custom post types – Gravity Forms + Custom Post Types – hasn’t been updated in over 2 years, so I’m reluctant to use it. I have the WP Types plugin which is capable of creating custom post types. I’m assuming I can use that in its place and achieve the same effect? Any suggestions? Thanks!

    • David Smith says

      Hi Kim, WP Types will actually create new custom post types. GF + Custom Post Types doesn’t create new custom post types. It lets you say, “This Gravity Form should create a post of “x” post type. You’ll need both. :)

      As far as GF + Custom Post Types not having been updated in a couple years… Haha, short answer is, not much has changed in a couple years. I know Gravity Forms support still recommends this plugin and there’s been no reports of users having issues with it.

      Happy to answer any other questions. :)

  6. says

    Really helpful post thanks. Please could you let me know whether this Gravity Forms add-on allows the user to select a format when they create a post using the form? For example, can the user choose whether it will be a video post, a link, etc.? Thanks very much

  7. John says

    Hay David, I am looking for a quick minute of your time to to bounce my requirement with you

    I want to create a petition entry Form I want to collect several data fields to include User NickName First Name Last Name City Country Custom 1 Reasons for signing And some options from pre set field drop downs Drop down Field 1 Drop down Field 2 Drop down Field 3

    I want to display each individual petition submissions as a post.

    Page to look something like this. (I can set up the Petition description as a sticky post)

    https://www.change.org/p/theresa-may-british-home-secretary-end-the-detention-of-women-who-seek-asylum

    I want to generate posts for each petition submission and to show specify fields only.

    NickName Reason for signing Drop down Fields 1 Drop down Fields 2 Drop down Fields 3

    So my question is really : Can I generate posts to contain more just the “Reason for signing” but include other specified data fields collected from a Form

    My site is a non profit – seeking public awareness

    Many thanks for your time to respond.

    J

    • David Smith says

      Hi John,

      Yes, Gravity Forms can store almost any data with the generated post. Most commonly, this is done with the “Custom Field” field type. After adding a custom field to your form, you can select which “type” of field it is (i.e. drop down, single line text, checkbox, etc) and also specify which custom field it should map to on your post.

      To actually display the custom fields on the frontend with your post you will need to either find a plugin that can help with this or write some custom PHP that handles this. See the “Custom Fields” section in this post for more details.

    • Alex says

      Added the code , nothing happends . It’s supposed to add the post merge tags to advance tab > default value field dropdown , right ?:D Fyi , using gravity forms 1.8.11 along with Gravity Forms + Custom Post Types , if that’s of any use .

      Thanks for the quick reply ;p

    • David Smith says

      Hi Mason, yup this is possible. Your example would just require a little configuration of the Post Content Template (a default Gravity Forms feature) and some CSS styling. You won’t need Gravity Perks to accomplish this but if you want to use our affiliate link when you purchase Gravity Forms, we’d be much obliged. :)

      Buy Gravity Forms

    • Mason L says

      Thanks David. Definitely will purchase through your link. Will definitely be purchasing GP as well. One more question for you, since you guys are so helpful and GF doesn’t have sales support.

      If I want to tie in user submitted posts with the membership feature, do I need the dev, biz, or basic license? Thanks again!

    • David Smith says

      You’ll want a developer license so you can register the user with the User Registration add-on. This add-on also handles attributing the post to the newly created user after the form is submitted.

  8. says

    Hi, thanks for the article. Is there a way to build the body of the post, from several individual fields? I’m thinking of asking a couple of questions to people and showing the answer like an interview (question, + answer of the user; next question + answer on second question; …) and this combined with a upload from a picture and that kind of stuff. categories and tags would be insterted automaticly (and not shown to the user). Would I be able to do that with Gravity forms and some extensions?

    thx for the support

  9. Anthony says

    Very informative, thanks! I’m thinking of going with Gravity Forms to achieve what I’m looking for – I’m creating a nightlife directory where users will submit events (custom post types) and venues (pages) to be featured on the site.

    My only question is what is the best way to achieve an area where users can manage their submissions? (ie, whether the post is Pending or Approved/Published)

    Obviously this would require a user login/registration page so I’ve been looking at the WooCommerce+Gravity Forms extension, but got a little scared when it said “Not yet supported: Post creation fields”

    Was hoping you could point me in the right direction for the extensions I would need to make this work

    • David Smith says

      Assuming you’d like to keep as much of the management on the front-end as possible here is a list of plugins I would use and why:

      • Gravity Forms
        It provides the basic functionality for user-submitted content, in your case, events and venues.
      • Gravity Forms User Registration Add-on
        Allows you to register users on your WordPress site per form.
      • Gravity Forms Payment Add-on (Stripe, PayPal, Auth.net, etc)
        Any of the Gravity Forms payment add-ons will allow you to charge users to either register on the site or per submission.
      • Gravity Forms: Post Updates
        I have not personally used this add-on but reading the feature list it sounds like it would allow you to let your registered users manage the posts they’ve created via Gravity Forms from the front-end.

      You should also check out our article on creating membership sites with Gravity Forms. Lots of good info in there. :)

  10. Alex says

    Thanks for the tut ! Now , here’s one for you : will i be able to filter my posts based on the custom fields used ? Let’s say i add a country field , which users needs to select to be displayed in post . Can i filter/sort my posts to only show posts made from specific contry ? Thanks !

    • David Smith says

      Hi Alex, this isn’t currently possible without additional custom code as the Address field type does not offer a merge tag for accessing individually inputs, such as the country. All the address data is provided in a string. If you are comfortable using a separate country field, you could add this as a Custom Field which would map it a custom field on the generated post. You could then create a custom query on whichever page you want to show country-specific posts using the Custom Field parameter of the WP_Query class.

  11. Brandon Pierce says

    Is there a method for pulling the auto-generated post’s URL to be included in a notification that is sent upon completion of the form?

    Thanks for this article, it has been awesomely helpful. The folks at Gravity Forms suggested it to me when I outlined our goal.

  12. Richard says

    But on your demo the featured image shows twice, as an attachment and as the top featured image above the post. This seems to be a common problem with front end submission plugins. How to prevent this? Thanks.

    • David Smith says

      Hi Richard, in this case, I’ve added the image to the post body intentionally just to demonstrate that you can do this automagically with Gravity Forms via the “Post Content Template” setting. The featured image above the post is handled by the theme but you don’t have to output the image in the post body as well.

  13. Oliver says

    Hi David,

    me again struggling with the query…

    I have set up the form for user submission with gravity forms (excellent product!!!) and everything works fine now. But how can i do sth. like this: I have captured the name (user-name) and email (user-email) and want make the displayed user name clickable (with a query to list all posts of this user. Or the field nationality (user-nationality) clickable with a query to list all post of this nationality.

    Sorry for this dumb questions, but i don´t know how to solve it. I have seen http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters but don´t know how to use it.

    Can you please advise me with one example? Best way for me would be to use the “Allow field to be populated dynamically”-function of gravity. Thanks a lot in advance.

  14. Oliver says

    Hi David,

    thank you very much for this tutorial. This is exactly what I´m looking for. But I have one question. I want users to submit posts with pictures without registration. But I want to manage the users, i.g. show a list of users with the number of pictures they have posted, etc. Can I do that with custom fields like “Contributor” and ask the users in the form for their name? And how can I relate/connect the data (user, picture, text, date, etc). Thanks in advance. Oliver

    • David Smith says

      Absolutely. If you want to store the name of the contributing user as a custom field on the generated post, just created a new Post Custom Field field and set the “Custom Field Name” setting to “contributor” (or whatever you’d like it to be called). To make it more identifiable to a single user, I’d probably also capture the user’s email as a custom field as well.

      As far as connecting the data, I assume you mean query for all posts submitted by a user (as defined by the “contributor”), the WP Query class provides a powerful and flexible way to search posts by post meta (aka custom fields).

  15. says

    Great run down of the post creation functionality. I’m actually having a challenge to auto create excerpts based on data from the submission – wonder if you can help.

    I am working with CPTs in this case and creating job postings for employees advertsing jobs. All data from the forms get put into a nice tidy table – no problem.

    Thing is, I also want to create a custom excerpt based on the submission showing: Employer, Job type, location and start date – 4 of the fields on the job submission form.

    Unfortunately the merge tags are not available on the excerpt creation field….

    Any ideas?

    • David Smith says

      Hi Robert, assuming the user is not entering their own excerpt, here is a system that might work.

      1 – Add an excerpt field to the form. 2 – Add a default value to this field using the “Default Value” setting (on the Advanced Tab). The default value can include any merge tags that you want. 3 – Add the “gf_hidden” class to the “CSS Class Name” setting so the field will be submitted with the form but not be visible to the user. 3 – Paste this snippet into your theme’s functions.php file: http://pastie.org/8603929 It will replace the merge tags in the Post Excerpt default value.

      This code was written on the fly and not tested… so let me know how it works out. ;)

  16. Chan says

    Hi David, thanks for the great post. I’m curious if there would be any way to make custom field (date/time) as the date/time to publish the post? (i.e, once the form is submitted, the post is saved as draft with the date/time they have chosen). Any chance to accomplish this? Thanks much!

  17. says

    Hi David, thank you very much for all of your info. I have 2 quick questions on this topic:

    1.) If I’m using BuddyPress, how can I show the post under the authors user profile page? Sort of how BuddyPress does it by default if you post via WP.

    2.) Does this process enforce a user to be logged in? If not, how can I make sure that only logged in users can post?

    Thank you!

    -Andy.

    • David Smith says

      Hi Andy, Gravity Forms provides a an option on the form settings to require the user be logged in. Once the user is logged in and fills out the form, it will automatically attribute that post to the user if you have the “Use logged in user as author” option checked: http://grab.by/qBIo I’m assuming with the form configured as such, it will integrate automatically with BuddyPress’ profile page.

  18. Matt says

    I’m trying to use the Gravity Forms survey add-on to set up a survey page where users can submit a star rating and a comment. Then, I’d like for those stars and comments to be displayed as posts on another page. There’s obviously no post fields for the advanced survey fields, but can you think of any workaround or advice? This is an awesome tutorial, by the way.

    • says

      I was able to work around this by adding a new field with a merge tag that collects the rating and saves it in a custom field (then the rating can be displayed in any template).

  19. Chris says

    Great tutorial! Especially for non-coders it is very easy to understand. Thanks Gravity and David!

    There is one thing you might help out: How do I create a custom field for all posts and how do I make it appear on my site?

    Gravity Forms provides such an option to add custom fields, but doesn’t make it appear, as you mentioned.

    What I need for my submission form is a simple field in which my visitors additionally can enter the price for hotels/hostels which they are suggesting by posting on my blog. You understand?

    This field should be shown below/above the post image.

    I’ve seen the documentation on WordPress.org, but I didn’t understand it because it seems that this documentation only provides how to show a predefined content. Or am I wrong?

    Please, need help!

  20. sofie says

    Hi David,

    A very useful article. Can you help me with the following. I would like to show the categories (as in “post fields > category” in a certain order. Now it is sorted alphabetically but showing numbers gives a strange result :

    100 participants 150 participants 20 participants 40 participants

    It would be great to re-order the categories from small (20 participants) to big. Is this possible?

    • Matthew says

      Our world be a single form. The form fields would be name, email, question, and answer. The form would show on front end every field but the answer field. The answer field would only show on the back end. Once the answer field is filed in from the back end the form would post to add custom post type and email a copy to the user that submitted the question.

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=""> <strike> <strong>