PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Using custom post fields to include data in a post?

  1. I am trying to use Gravity Forms to create a front-end post tool for registered users. The purpose is to post an item to a classified ad, and posts will be entered as drafts for admins to publish.

    My form is set up, and almost all fields are from the post field custom fields button in the form creator. However once the form is submitted and I open the pending post in the post editor to moderate, I don't see how the custom post field data can be published to the post.

    My form can be previewed here: http://wmdpg.org.previewdns.com/member-services/member-market/submission-form/

    2 of the custom fields show up in the post editor's custom fields section, but not when I publish the post itself (preview here: http://wmdpg.org.previewdns.com/2010/11/product-name/. Only the title field shows, since its the title of the post.

    Do I have to create custom fields in my single.php file to handle the custom fields from the gravity form? Or some other custom template file to handle the custom fields? How do I get the user-submitted data from the gravity form and into a live post on my site?

    Posted 13 years ago on Sunday November 21, 2010 | Permalink
  2. First you need to make sure you gave your Custom Fields names, otherwise the data won't get saved. The name is the custom field key. Edit each of your Custom Fields fields in the form builder and make sure that the name option in the Properties tab is populated with an existing custom field name, or a new custom field name. See this screenshot:

    http://grab.by/7ww1

    You either need to select an existing custom field name, or select New and give it a unique name. The name is the custom field key. This is what is used to display that custom field in your theme, etc.

    Next, Custom Fields aren't automatically added to the post body when a post is displayed in WordPress. Your theme has to tell a custom field to be displayed. See this WordPress codex article on Custom Fields:

    http://codex.wordpress.org/Custom_Fields

    Gravity Forms does provide a tool to display custom field values (or any form field value) in the Post Body and Post Title. This is called a content template. It is a feature on the Post Body and Post Title fields. It is similar to how you setup email notifications for a form, you use form field variables that are replaced with the correct values when the post is created.

    See this screenshot:

    http://grab.by/7ww7

    So you either need to edit your theme and display the custom fields or you need to use the content template of the Post Body field in Gravity Forms to display the value of the custom fields. They aren't displayed automatically.

    Posted 13 years ago on Monday November 22, 2010 | Permalink
  3. Carl - This is incredibly helpful. I used the Post Body field to display the values of the other fields in the forms, and achieved my desired post. Thanks so much!

    One last question - It seems like the Post Body field needs to be a separate field on its own. I can't get it to display its own user-entered text in addition to the values of the other fields. See my form again at this link.

    The paragraph field "About this Product" is the Post Body field, but its redundant with "Describe the Product or Service" for my users. And anything they type in "About this Product" does not display, despite calling the field. Is there a trick to displaying both text submitted AND data from other fields in the Post Body field?

    Posted 13 years ago on Monday November 22, 2010 | Permalink
  4. When you turn on the Content Template for the Post Body field you also have to then insert the form field variable for the Post Body field into the Content Template if you want it to be output. This is because you can actually hide the Post Body field by setting it's visibility to Admin Only and not display the actual field on the form. So it's flexible.

    Posted 13 years ago on Monday November 22, 2010 | Permalink