Please Note: We are no longer using forums to facilitate standard support. 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.

Displaying data from a field in a form using simple hook or php code

  1. sfejokwu
    Member

    First, I apologize if this question has been answered already. I searched the forum and did not find any questions or solutions that answered my question completely.

    I have a post form set up for users to enter their "Nickname" and other field entries and submit their post. ( http://mydeargirlfriend.com/share-yours/ ) . I have simple hooks, which is a plugin that allows me to execute php codes or shortcodes at various points of the code execution process in post, pages, etc. I was trying to see if there is a way for me to display the data of various fields that users enter in my form on every post. For example, I want the data that a user enters in the "Nickname" text field to be displayed just below the post title as say Author: [text entered in Nickname field here]. So I wanted to see if there is php code for this or short code I can use to execute this function or other way to do this? Please let me know if this is possible. I have looked around the web and in this forum and I haven't quite find a solution that addresses what I am looking for. Thanks a lot guys!

    Posted 4 years ago on Saturday January 22, 2011 | Permalink
  2. If you are using Gravity Forms to create WordPress posts then you can add Post Custom Fields to your form. The data gets stored in the post meta table as a custom field for the post is created. To display custom field data on your post you have to modify your theme to display post meta. You can read up on WordPress custom fields here:

    http://codex.wordpress.org/Custom_Fields

    An alternative way of displaying the value of other form fields within the post body of the post that is created is to use the Content Template functionality of Gravity Forms. To do this you would:

    - Edit your form
    - Edit your Post Body field
    - Turn on the Content Template functionality
    - Create your Content Template in the textarea provided using the "Insert form field" drop down to insert the value of form fields dynamically. Please be aware if you use the Content Template you need to be sure to select the Post Body variable to display that field as well. Whatever you put in the Content Template will be used to create the Post Body content.

    Posted 4 years ago on Saturday January 22, 2011 | Permalink
  3. sfejokwu
    Member

    Thanks, Carl. Is there a shortcode to use to display the data in a particular field in a form. My theme allows me to hook shortcodes and I was wondering if there was that the data entered in a particular field is displayed by using a shortcode? Thanks.

    Posted 4 years ago on Saturday January 22, 2011 | Permalink
  4. No, the Content Template I described above works in similar fashion to using shortcodes and it also accepts shortcodes in the Content Template itself. So if you use the Content Template functionality you could accomplish what you want to do.

    Once Gravity Forms creates the post, it doesn't have anything to do with the post directly. It's a standard WordPress post at that time. So there are no shortcodes for displaying form field values in the post because of that.

    But as I explained above, using the Content Template functionality of the Post Body field you can insert form field variables (which are kinda like shortcodes as they are replaced with the value of the form field once they are processed) as well as use shortcodes in the Content Templates to control the content of the post that is created.

    Posted 4 years ago on Saturday January 22, 2011 | Permalink

 

Support Tickets

Open A New Support Ticket
 Open A New Priority Support Ticket *

* Developer license holders only