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.

Front-end Form Creation

  1. Hiya folks!

    On a client site I'm using GF to provide form creation on the front-end of WordPress (with user role permissions). The user never has to visit the admin or deal with any WordPress components. However, we've run into a snafu with elements such as the Page Break.

    When creating a form (since we're on the front end) a saved form with a page break will show the 'next' button rather than the page break editor and the rest of the form doesn't show.

    What we've done currently is added to the define to gravityforms.php and a slight change to preview.php to make form previews work properly - just one line in each file. This is because the hack binds the define a bit too late, on "wp" hook, which is when a lot of the page
    rewriting plugins are deciding if the user is on the right page. It's also bound a bit too late for preview.php, but since it's a fixed point in execution, it's OK to just define what's needed there (imho, of course).

    The changes are in file gravityforms.php on line 60/61:

    if(!defined("IS_ADMIN"))
        //define("IS_ADMIN",  is_admin());
    	add_action('wp', create_function('', 'define("IS_ADMIN", apply_filters("gf-is_admin-filter_name-here", is_admin()));')); // A hack to make multiple step forms editing possible

    Then in preview.php on line 2:

    define("IS_ADMIN", false); // A hack to make the previews work with the front-pages hack (main file)
    for ( $i = 0; $i < $depth = 10; $i++ ) {

    For now, we'll continue to implement this change in each revision but if the above (or a filter rather than a define) could be considered we'd greatly appreciate it.

    Thanks!

    Posted 12 years ago on Sunday January 29, 2012 | Permalink