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.

pass data to form

  1. is there anyway to pass data to a form so it populates the form. for example if i have a page that is of a car and i want to get more info about the car then clicking a get more info button which links to a page with a form on then passes the car name to the form.

    is this possible?

    Posted 15 years ago on Sunday October 4, 2009 | Permalink
  2. It will be possible in the v1.2 release which will be released as a beta on Monday or Tuesday. The beta will be available for download to license holders here on GravityHelp.com once it is released. It will not be available via automatic upgrade until it is out of beta.

    This will be one of many new features that will be introduced in the v1.2 release.

    Posted 15 years ago on Sunday October 4, 2009 | Permalink
  3. great this will be a very good feature i look forward to the beta release

    Posted 15 years ago on Sunday October 4, 2009 | Permalink
  4. now that 1.2 has been released is this now possible?
    either that or is it possible to have a form on the page that automatically populates the posts title into the message field?

    Posted 15 years ago on Friday October 16, 2009 | Permalink
  5. Yes you can do this with 1.2 You can either pass data to a field using the query string, hook, shortcode or function call.

    Look at the "Dynamic Field Population" section and video on this post:

    http://www.gravityhelp.com/gravity-forms-v1-2-released/

    Posted 15 years ago on Friday October 16, 2009 | Permalink
  6. thanks carl ill check that out. what would be good for a future release is to be able to put in the edit mode something like {the_title} into the field you want populated with the page title for example. then the form can be on the page and be automatically populated with that data

    Posted 15 years ago on Friday October 16, 2009 | Permalink
  7. next year
    Member

    I am searching for way to insert the post title to the data field.

    I am not still understand how to do it. I have been watching the video. I understand that I can pass variable using http://mydomain.com/page/?id=adada. But still not understand how to pass post title to the data field.

    Please help.

    Posted 15 years ago on Monday October 26, 2009 | Permalink
  8. You will need to write a little bit of PHP to do that. The following should help you. (The assumption is that the form is embeded in the post you would like to get the title from)

    1- Add the Post Title field to your form
    a- Allow it to be populated dynamically (advanced tab)
    b- Type "posttitle" in the "parameter name" text field

    2- Add the following code snippet to your template's function.php file


    add_filter("gform_field_value_posttitle", "populate_post_title");
    function populate_post_title(){
    global $post;
    return $post->post_title);
    }

    Posted 15 years ago on Tuesday October 27, 2009 | Permalink
  9. next year
    Member

    WIll try it

    Parse error: syntax error, unexpected ')' in /home/domain/public_html/wp-content/themes/mythemes/functions.php on line 48

    It should be

    add_filter('gform_field_value_posttitle', 'populate_post_title');
    function populate_post_title(){
    global $post;
    return ($post->post_title);
    }

    Posted 15 years ago on Tuesday October 27, 2009 | Permalink
  10. next year
    Member

    Thanks alot. It works now. :)

    Posted 15 years ago on Tuesday October 27, 2009 | Permalink
  11. Cool, good to hear you got it working!

    Posted 15 years ago on Wednesday October 28, 2009 | Permalink
  12. next year
    Member

    Now that I have added title to the data field. How do I add 'custom fields' in post to the data field in gravity forms.

    For example, when I'm creating new post, I have set 'custom fields' price in the post. How do I add 'price' field to the data field in gravity forms?

    Please help. Let me know.
    Thanks

    Posted 15 years ago on Saturday October 31, 2009 | Permalink
  13. alexinfiniti
    Member

    I want a member of my site to login, and once they visit the contact form i want the fields to automatically populate themselves using the information in their profile. These are the same fields in all wordpress signup pages. Can someone help me out?

    :D

    Posted 15 years ago on Sunday November 1, 2009 | Permalink
  14. Next year,

    Use the following code snipped to populate a field with a post custom field


    add_filter('gform_field_value_postcustom', 'populate_postcustom');
    function populate_postcustom(){
    global $post;
    return get_post_meta($post->ID, "my_custom_field", true);
    }

    Note: Replace "my_custom_field" with your custom field name and "postcustom" with your field's parameter name

    Posted 15 years ago on Monday November 2, 2009 | Permalink
  15. alexinfiniti,
    I will give you instructions to populate a field with the WP username.
    You will need to repeat it for each field you want to populate (i.e. First name, Last name, email, etc)

    1- Add the Username field to your form
    a- Allow it to be populated dynamically (advanced tab)
    b- Type "username" in the "parameter name" text field

    2- Add the following code snippet to your template's function.php file

    add_filter('gform_field_value_username', 'populate_username');
    function populate_username(){
    global $userdata;
    //populating field with the username
    return $userdata->user_login;
    }

    Posted 15 years ago on Monday November 2, 2009 | Permalink
  16. alexinfinity,
    To populate other user related fields, replace the following line:


    return $userdata->user_login;

    with one of the following:

    1- to populate field with display name

    return $userdata->display_name;

    2- to populate field with email

    return $userdata->user_email;

    3- to populate field with url

    return $userdata->user_url;

    4- to populate field with status:

    return $userdata->user_status;

    Posted 15 years ago on Monday November 2, 2009 | Permalink
  17. sorry to hijack this thread again but i thought my question is relative to this.

    Is it possible for me to create a link with a query in it to pass the text to a gf form?

    sor for example the url would be http://www.domain.com/contactpage.htm?pass=datatpass

    then 'datatopass' is input into the form automatically

    is this possible?

    Posted 14 years ago on Friday February 19, 2010 | Permalink
  18. Yes, you can pass data to pre-populate a field using the query string.

    You need to turn on dynamic data population for each field you want to do this with, and then give it a parameter name when you do so.

    That parameter name is then what you use int he query string to pass the data to the form.

    So if you have a field for email, you can edit the advanced settings for that field and turn on dynamic data population and then give that field a parameter name of email.

    Then when loading the page with the form on it you would pass ?email=VALUE and the field would be pre-populated using that value.

    Posted 14 years ago on Friday February 19, 2010 | Permalink

This topic has been resolved and has been closed to new replies.