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.

2 Forms in Nav Bar

  1. Hi there, my URL is http://74.54.88.165/~rwatchi/. I have placed two images in the top navigation bar and each one should link to a form. The first is Email This Page, which should email the url of the page the form is filled out on. The form is set up with an Email field and a hidden field using {embed_url}. Then {embed_url} is inserted into the Body of the notification email sent to the Email address the user fills out in the form field. On the form, the Field Label is url, I have checked to allow to populate dynamically, and the Parameter Name is refurl. Looking thru the forum, I found a snippet that I put in functions.php 'add_filter("gform_field_value_refurl", "referral_url");
    function referral_url($form){
    //Grab URL from HTTP Server Var and put it into a variable
    $refurl = $_SERVER['HTTP_REFERER'];

    //Return that value to the form
    return esc_url_raw($refurl);
    }'

    The second form is linked to the image "Product Tour", and is simply designed to capture the Name, Company Name and Email address of the person who is taking the tour (clicks on the button and fills out the form). Nothing special with this form, very simple.
    In looking thru the forum and documentation, it looks like I need to use tabindex for more than one form on a page, so I have added 'add_filter("gform_tabindex", create_function("", "return 1;"));' to the functions.php file, and also added '<?php
    gravity_form_enqueue_scripts(3,4, true);
    ?>' in the header.php file. (Not sure of the syntax for allowing forms 3 & 4 ??)
    I wish to display both forms in a Fancybox, so I have installed Easy FancyBox and added this code to my functions.php: 'add_filter ('wp_nav_menu_menu_items','add_producttour', 10, 2);
    function add_producttour($items, $args) {
    $items .= '<li class="my-contactus"><div style="display:none" class="fancybox-hidden"><div id="fancyboxID-1"> <?php gravity_form(3, true, true, "", "", true, 4); ?> </div></div><img src="http://74.54.88.165/~rwatchi/wp-content/themes/BuilderChild-Default/images/ptnav.png" alt="Product Tour" />';
    return $items;
    }
    add_filter ('wp_nav_menu_menu_items','add_contactus', 10, 2);
    function add_contactus($items, $args) {
    $items .= '<li class="my-contactus"><div style="display:none" class="fancybox-hidden"><div id="fancyboxID-1"> <?php gravity_form(4, true, true, "", "", true, 1); ?> </div></div><img src="http://74.54.88.165/~rwatchi/wp-content/themes/BuilderChild-Default/images/emailnav.png" border="0">';
    return $items;
    }'
    I had to change the single quotes in the GF parameters because it was giving an error. I've tried single quotes, double quotes and just a space without any luck. I do not know php very well.
    I have used the FancyBox plugin on another site w/GForms with no problems, but as you can see when you go to the URL, it's not working and I've tried searching the forums and documentation....can you please help? Thanks so much.

    Posted 7 years ago on Monday June 11, 2012 | Permalink
  2. David Peralty
    Administrator

    After a quick search, I found the following:

    Note - ID's are meant for a SINGLE instance. If you want to use the same script for all your images/elements then use classes instead.

    http://fancybox.net/howto

    Try to change it to classes, and see if that helps or works. Also, try one form and see if that works before moving on to two. This doesn't seem like it should be a Gravity Forms issue, so if you can do some troubleshooting for us, to rule out anything else, I would really appreciate it.

    Posted 7 years ago on Tuesday June 12, 2012 | Permalink
  3. Thanks for the quick reply. So I have removed one of the forms to try to get a single form to work before going to the second. Here's what I have in functions.php,
    'add_filter("gform_tabindex", create_function("", "return 1;"));

    add_filter ('wp_nav_menu_menu_items','add_producttour', 10, 2);
    function add_producttour($items, $args) {
    $items .= '<li class="my-contactus"><div style="display:none" class="fancybox-hidden"><div id="fancyboxID"> <?php gravity_form(3, true, true, true, 4); ?> </div></div><img src="http://74.54.88.165/~rwatchi/wp-content/themes/BuilderChild-Default/images/ptnav.png" alt="Product Tour" />';
    return $items;
    }

    add_filter("gform_field_value_refurl", "referral_url");
    function referral_url($form){
    //Grab URL from HTTP Server Var and put it into a variable
    $refurl = $_SERVER['HTTP_REFERER'];

    //Return that value to the form
    return esc_url_raw($refurl);
    }'
    This is for the Email to a Friend form. Searching the Fancybox forum I found this post on classes/ID's:
    https://groups.google.com/group/fancybox/browse_thread/thread/736736f5d556c67b#
    The URL to the site is: http://74.54.88.165/~rwatchi/ and it still doesn't display the form. I've tried modifying this code in the functions.php ('<?php gravity_form(3, true, true, true, 4); ?>') because when I use single quotes for the $field_values attribute it would give an error. I even tried to use echo do_shortcode to avoid the single quotes. I'm really struggling here and looking for World Class Support that you guys are know for...I think it's close and if you would like access to login if you think that would help I can provide it via email. Thanks for all you do.

    Posted 7 years ago on Tuesday June 12, 2012 | Permalink
  4. Hi there. I tried the suggestion and still awaiting reply. Thanks for all you do.

    Posted 7 years ago on Thursday June 14, 2012 | Permalink
  5. David Peralty
    Administrator

    I can't find the mention of wp_nav_menu_menu_items anywhere on WordPress' website. Can you link me to where you found this filter hook?

    Posted 7 years ago on Thursday June 14, 2012 | Permalink
  6. Menu is the name of the Top Nav Bar Menu I created in WP Custom Menus. I found the post here: http://websitesetuppro.com/how-to-open-gravity-forms-form-in-a-lightbox/

    Posted 7 years ago on Thursday June 14, 2012 | Permalink
  7. In the term wp_nav_menu_menu_items, the first occurrence of "menu" is the name of the Custom WP Menu, it just so happens I named it menu. If I called the menu Top Nav then it would be wp_nav_top-nav_menu_items. Hope that helps.

    Posted 7 years ago on Thursday June 14, 2012 | Permalink
  8. David Peralty
    Administrator

    Okay, I understand now. You mention you are currently using this, but I don't see the code on your page. When I do a search for "fancybox-hidden", I don't see anything other than the javascript call. Once you get the menu item showing properly, then I can help you with any Gravity Forms issues that come up.

    Posted 7 years ago on Thursday June 14, 2012 | Permalink
  9. I think the confusion lies in the fact that I'm using Builder by iThemes, and I think the term comes from within Builder...

    Posted 7 years ago on Thursday June 14, 2012 | Permalink
  10. David Peralty
    Administrator

    No, it is a WordPress hook, I just had never heard of it before. (With several hundred existing, I'm not surprised one on menu control slipped past).

    If you can get the menu to output your code, then we should be one step closer to solving your issue though.

    If you use that add_filter to create just a simple menu item, does it work?

    Something like

    add_filter ('wp_nav_menu_menu_items','add_producttour', 10, 2);
    function add_producttour($items, $args) {
    $items .= '<strong>Test</strong>';
    return $items;
    }
    Posted 7 years ago on Thursday June 14, 2012 | Permalink
  11. Yep, works just fine. You have to look close because the text is BLACK and it is on the Navy blue background between NEWS/EVENTS and the orange Email Page button.
    http://74.54.88.165/~rwatchi/

    Posted 7 years ago on Thursday June 14, 2012 | Permalink
  12. I've got the menu to output the GF code as well. The URL is http://74.54.88.165/~rwatchi/ and if you click on the Email Page button in the Nav Bar, you can see the Fancybox animates and tries to open the GF, but there is no form being shown. The code in the menu hook is:
    add_filter ('wp_nav_menu_menu_items','add_producttour', 10, 2);
    function add_producttour($items, $args) {
    $items .= '<li class="my-contactus"><div style="display:none" class="fancybox-hidden"><div id="fancyboxID"> <?php gravity_form(3, true, true, true, 4); ?> </div></div><img src="http://74.54.88.165/~rwatchi/wp-content/themes/BuilderChild-Default/images/ptnav.png" alt="Product Tour" />';
    return $items;
    }
    I tried to follow the documentation in GF for embedding a form using php, but if I used single quotes for the $field_values parameter it would throw an error. I still can't get the form to display.....

    Posted 7 years ago on Friday June 15, 2012 | Permalink
  13. The box appears but the form does not display...still need some help. Thanks for all you do.

    Posted 7 years ago on Monday June 18, 2012 | Permalink