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.

Embedding GF on html page

  1. csenglim
    Member

    How can I embed the created GF into a HTML page residing in a protected member's only directory? I only know a few measly html codes, need all the help I can get.

    Thank you
    Cseng Lim

    Posted 14 years ago on Sunday April 4, 2010 | Permalink
  2. Gravity Forms has to execute within a WordPress page or post, it's a WordPress plugin so it can't be executed on a static HTML page. So it would have to reside on a WordPress post or page.

    Posted 14 years ago on Monday April 5, 2010 | Permalink
  3. I was actually working on something like this so I figured I would post my solution here. First though, I would suggest to csenglim that you find a way to make your member's only directory a WordPress page, then just hide it. You can use WordPress and Gravity Forms functions outside WordPress, but you have to ask yourself why. I did ask myself why, and for the integration I was doing, I needed to do something similar.

    So, I followed the instructions here to have access to WordPress functions outside WordPress (you basically include wp-load.php):

    http://wpengineer.com/embed-wordpress-functions-outside-wordpress/

    Then, I copied the index.php from my theme, and took out all the code related to "the loop", comments, meta, date, author, etc. I did this so that the page would look basically like all the other pages on the site (top menu, sidebar, content area, footer, etc.)

    Once that was done (I basically had a header, footer, sidebar and content divs) I embedded the form and necessary scripts and CSS following these instructions:

    http://www.gravityhelp.com/documentation/embedding-a-form/

    This is the result:
    http://www.riversidehalloweenwindows.org/members-only/

    That is *not* a WordPress page. It is index.php in a directory called members-only. Here is the code:

    <?php
    // include wordpress and gravity forms outside wordpress
    require( '../wp-load.php' );
    wp_enqueue_script("gforms_ui_datepicker", WP_PLUGIN_URL . "/gravityforms/js/jquery-ui/ui.datepicker.js", array("jquery"), "1.3.9", true);
    wp_enqueue_script("gforms_datepicker", WP_PLUGIN_URL . "/gravityforms/js/datepicker.js", array("gforms_ui_datepicker"), "1.3.9", true);
    wp_enqueue_script("gforms_conditional_logic_lib", WP_PLUGIN_URL . "/gravityforms/js/conditional_logic.js", array("gforms_ui_datepicker"), "1.3.9", true);
    wp_enqueue_style("gforms_css", WP_PLUGIN_URL . "/gravityforms/css/forms.css");
    get_header(); ?>
    <div id="content">
            <div id="contentleft">
                    <div class="postarea">
                            <h1>My Membership Page</h1>
                            <div class="form">
                                    <?php gravity_form(2, false, true); ?>
                            </div>
                    </div>
            </div>
    <?php include(TEMPLATEPATH."/sidebar.php");?>
    </div>
    <?php get_footer(); ?>

    The path to your wp-load.php may be different based on where your directory is located in relationship to your WordPress installation. You may need to change the 2 in the gravity_forms call to your actual form number.

    I tested this and it submitted and works fine, and the entry is captured by Gravity Forms/WordPress. The email notification was sent. It's very cool that you can do this.

    Hope that helps.

    Feel free to submit that form; it won't hurt anything.

    Posted 14 years ago on Monday April 5, 2010 | Permalink
  4. csenglim
    Member

    Wow thanks ...it will take me a couple of days to figure all this out but it's a solution that I will definitely try. Thanks for the information.

    I think GF is such a great solution, but it can be greater still if you guys at GF is willing to explore more than just tying it to WP ..why limit yourself when you can offer something really great. I think 80% of the interactions online is via a form or some form of submission...

    Posted 14 years ago on Tuesday April 6, 2010 | Permalink