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.

Identify which page form is loaded from

  1. Is it possible to identify which page the form was launched from?

    <a href="http://www.domain.com/form-page" class="colorboxiframe">Form Page</a>

    The form shortcode is on a Wordpress Page called "form-page".

    The form is loaded with an iframe using colorbox.

    The above code is inserted automatically to a number of pages. I need to know when the user fills out the form where they came from...

    any other ideas on how to achieve the same thing?

    Posted 12 years ago on Sunday October 14, 2012 | Permalink
  2. So, you are calling the form page from multiple pages, and the "embed URL" will not work because it would always be "form-page"? Normally, the embed URL is the page the form is launched from. That is true even in your case, but that is not the URL you want.

    The code is inserted automatically into multiple pages ... so you can't edit the shortcode? Can you explain how the shortcode is included in multiple pages automatically? I think you will need to have a hidden field in the form which is embedded in 'form-page' and include that field in the query string. Or, you can include a value in the short code:

    [gravityforms id=1 field_values='page_url=Page Title Here']

    That would populate a hidden field in your form with a parameter name of "page_url".

    Any thoughts?

    Posted 12 years ago on Monday October 15, 2012 | Permalink
  3. Yes that looks like what I want but not sure how to pass that value using an iframe... i think it's impossible so i will need to revise my process..

    To make things clearer

    1. A file called single-footer.php is loaded onto multiple pages.

    2. The file single-footer.php contains the launch code for the form which is:

    <a href="http://www.domain.com/form-page" class="colorboxiframe">Form Page</a>

    3. The class 'colorboxiframe' makes the form load into a popup iframe.

    Problem, how to pass the name of the page it was launched from to the hidden field. Presumably the necessary code needs to go to single-footer.php

    Posted 12 years ago on Monday October 15, 2012 | Permalink
  4. Form-page is just a plainpage template containing just [gravityform id=10]

    i think this step is causing the problem, so maybe we need code to launch the form directly..

    Posted 12 years ago on Monday October 15, 2012 | Permalink
  5. What if you captured the post ID in your single-footer.php, like this:

    [php]
    global $post;
    $thisid = $post->ID;

    Then, in the shortcode or function (your launch code) where you include the form, pre-populate the page ID in a hidden field. Would that work for you?

    I just tried it here:
    http://gravity.chrishajer.com/2012/08/22/map-to-fun/

    I added this code to my footer.php:

    [php]
    <?php
        global $post;
        $thisid = $post->ID;
        echo "<!-- You are on page " . site_url() . "/?p=" . $thisid . " -->";
    ?>

    If you look in the source of that page, you will see the HTML comment:

    [html]
    <!-- You are on page http:// gravity. chrishajer. com/?p=870 -->

    This code will work fine on a single page (like where your single-footer.php is likely in use.) It would not return the correct value when used on an index page or archive page, due to the loop.

    Posted 12 years ago on Monday October 15, 2012 | Permalink
  6. Based on your latest response, which was posted after my response, I think in your footer, where the link to the form is, you need to send a query string like this:

    http://www.domain.com/form-page/?frompage=$postid

    Where $postid is from my previous code. Then in form 10, you need to have a hidden field called "Source Page" or "Referring Page" or something, check the box on the advanced tab to "Allow Field to be Populated Dynamically" and enter a parameter name of frompage since that is what we are sending over from the single-footer.php.

    Can you put all those pieces together?

    Posted 12 years ago on Monday October 15, 2012 | Permalink
  7. i will try this out and let you know , thanks for the super prompt responses.

    Posted 12 years ago on Monday October 15, 2012 | Permalink
  8. ok, it's rather hard for me to work out.. i can't even get

    echo "<!-- You are on page " . site_url() . "/?p=" . $thisid . " -->";

    to show on the page, these are custom post types too.. would it be possible to send you my login details to test?

    Posted 12 years ago on Monday October 15, 2012 | Permalink
  9. update... i figured it out! but i used a hard-coded name :)

    http://www.domain.com/form-page?frompage=hard-coded

    so the only problem is to figure out each posts title which i thought would be the easier part using the code:

    <?php
        global $post;
        $thisid = $post->ID;
        echo "<!-- You are on page " . site_url() . "/?p=" . $thisid . " -->";
    ?>
    Posted 12 years ago on Monday October 15, 2012 | Permalink
  10. The custom post type uses this code to get the title of the page:

    <?
    php echo $event->post_id
    ?>

    how do i incorporate this to: $thisid

    this seems to be just a php fundamental issue..

    Posted 12 years ago on Monday October 15, 2012 | Permalink
  11. ok, in the end i just used

    <?php echo get_the_title(); ?>

    to pass the title of the page.

    problem solved. thanks a lot for the help :)

    Posted 12 years ago on Monday October 15, 2012 | Permalink
  12. Right on - glad you got it sorted out.

    Posted 12 years ago on Monday October 15, 2012 | Permalink

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