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.

Post title automaticly into form

  1. Is it possible if I'm in a post on my blog and I click on a link that says submit (or what ever) and that link forwards me to a gravity form that the post title of the post where I was will be automaticly put in the form as a field?

    Posted 14 years ago on Wednesday March 3, 2010 | Permalink
  2. You can only get the referrer url as a default value in a field, not the page name of the referrer url.

    What you could do is in your link to the form, pass the page name as a query string parameter to the form. Then in your form setup a field that can be populated dynamically using that query string parameter.

    This can be done by adding the link to the form in your post template file, and using PHP set it up so it passes the post name as a query string parameter value to the page that contains the form.

    See this post on using the query string to send values to a form:

    http://forum.gravityhelp.com/topic/sending-dynamic-form-variables-to-another-form

    Posted 14 years ago on Wednesday March 3, 2010 | Permalink
  3. @Carl,

    Thanks for the reply. I'm starting to get my way around with php. So I hope I will manage this.I'll try and comeback as it works :-)

    Posted 14 years ago on Tuesday March 9, 2010 | Permalink
  4. What I probably need is this query string: <?php post_title; ? >

    What php code do I need to get it sent to another page. Who has a tip for me to find info on that?

    Or should I already use a form on the first page where people click the link?

    I can show you where I need it: http://proefcollege.info
    If you go here you see in the post the link inschrijven. If you click that link you go to a form where people have to ad a name and some more. I also want the name of the post (= the referrer post name) sented in that form to the administrator of the website.

    Posted 14 years ago on Tuesday March 9, 2010 | Permalink
  5. Jan Egbert
    Member

    You can pass the post id via URL.

    So the URL for Proefcollege with post id 3 would be http://proefcollege.info/inschrijven-2/?proefcollege=3. You could easily achieve this within your loop.

    Just change:

    <a href="http://proefcollege.info/inschrijven-2/">Inschrijven</a>

    to:

    <a href="http://proefcollege.info/inschrijven-2/?proefcollege=<?php the_ID(); ?>">Inschrijven</a>

    In your themes functions.php add the following snippet:

    add_filter( 'gform_field_value_proefcollege', 'populate_proefcollege' );
    function populate_proefcollege(){
    	$proefcollege= get_the_title($_GET["proefcollege"]);
    	return $proefcollege;
    }
    Posted 14 years ago on Wednesday March 10, 2010 | Permalink
  6. @Jan Egbert,

    Thanks for the reply. I was working on it today, but it only shows this: Embed URL: .../ The dots and the slash are a link to: http://proefcollege.info/inschrijven-2/?proefcollege=%3C?php%20the_ID();%20?%3E. If I click that I will go to: http://proefcollege.info/inschrijven-2/

    But I want to know the title op the post the person was coming from when they came to http://proefcollege.info/inschrijven-2/

    Do you know what is going wrong?

    Posted 14 years ago on Wednesday March 17, 2010 | Permalink
  7. Perhaps I know what is going wrong. Perhaps I didn't explain well what I want.
    I have a site with posts on the front: in each post there is the link:
    'Inschrijven'

    With this link they get to the form that is on http://proefcollege.info/inschrijven-2/. I want the title of the post that is on the front of the website into the form.

    Posted 14 years ago on Wednesday March 17, 2010 | Permalink
  8. Jan's example above outlines how you would do this.

    You have to pass the id of the post they are coming from in the link to the form, and then you would use the API hook to read that id, get the title of the post, and then populate the field with it.

    Posted 14 years ago on Wednesday March 17, 2010 | Permalink
  9. @Carl, I think I do understand what you mean. I will try it. And will come back on it.

    Posted 14 years ago on Wednesday March 17, 2010 | Permalink
  10. I have looked at it, but I don't understand what I'm doing wrong. Should I use a new form field in my form I mad that gets the url of the post?

    Posted 14 years ago on Sunday March 21, 2010 | Permalink
  11. Thanks guys,
    I know what went wrong. I had to tell in my form the things below.

    Allow field to be populated dynamically (?)
    Parameter Name:

    I did that and now it works!

    Posted 14 years ago on Sunday March 21, 2010 | Permalink
  12. Will it be possible to get beside the Post title, also get the info of a custom field that is used?

    That it will be something like: <a href="http://proefcollege.info/inschrijven-2/?proefcollege=<?php the_ID(); ?><?php get_custom_field(); ?>">Inschrijven</a>

    Posted 14 years ago on Wednesday March 24, 2010 | Permalink
  13. Jan Egbert
    Member

    The post ID is the key to everything that is related to that single post. Calling for a custom field as you are trying above will only get custom fields for the page called Inschrijven.

    Example: If you want to pre-populate a hidden field called price you need to enable that field to be pre-populated and add the following snippet to your themes' functions.php.

    add_filter( 'gform_field_value_price', 'populate_price' );
    
    function populate_price(){
    
    $price = get_post_meta($_GET["proefcollege"], "price", true);
    
    	return $price;
    }

    Function reference for get_post_meta() : http://codex.wordpress.org/Function_Reference/get_post_meta

    Posted 14 years ago on Wednesday March 24, 2010 | Permalink
  14. BillFishkin
    Member

    The snippet given above by Jan Egbert IS NOT INCLUDED in documentation under Hooks and Filters. It took me nearly 2 hours to find this information. This should definitely be included in the documentation, as it is referenced in a gravity forms 'help bubble' but not explained anywhere other than here (unless I missed something!)

    Posted 14 years ago on Tuesday April 13, 2010 | Permalink
  15. There are a bunch of undocumented API hooks and filters that we plan on providing more documentation for in the near future.

    Posted 14 years ago on Tuesday April 13, 2010 | Permalink
  16. BillFishkin
    Member

    Thanks for the clarification Carl. Any chance you could give me the next best thing, the php file where I can find reference to said hooks and filters to figure it out on my own?

    Posted 14 years ago on Wednesday April 14, 2010 | Permalink
  17. I'm not sure what you mean, if you have Gravity Forms you already have the PHP. The hooks and filters exist within the plugin code itself across multiple files. They aren't contained in a single file.

    Posted 14 years ago on Wednesday April 14, 2010 | Permalink