Support » Plugins » Hacks » Using jQuery .load() function with wordpress and gravity forms

  • I am developing a series of pages which will integrate with Gravity Forms.

    I’m using jQuery to send data to a div from a page I have created.

    Requesting Page

    <a href="#" onclick="showEntry(\''.$url.'\')">View</a>
    <div id="viewEntry"></div>

    Javascript/jQuery page

    function showEntry(url){

    PHP data page – entry.php

    $form_id = $_GET['f'];
    $form = GFFormsModel::get_form_meta( $form_id );

    When ever I click run I get an error in my log file saying: PHP Fatal error: Class ‘GFFormsModel’ not found in

    I want to know how I can get the entry.php file recognizing all the classes in the rest of my WordPress file system.

    Any help would be great!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You can use the following code at the top of your PHP file to have access to WordPress classes

    include_once('path/to/wp-load.php' );

    You’ll have to change the path to actually point to where the wp-load.php file is actually located on your system.

    Moderator bcworkz


    Simalam is correct, and this will work fine for your own site where you know where your files are. If you want others to use your plugins on their sites, it’s not possible to reliably know where wp-load.php lies on any random installation.

    The only way for a php file to access WP resources and plugins on any system is to make it a page template where the code is invoked by requesting a page published based on the template.

    There are a couple other ways to get requested PHP code to access WP resources. The code needs to be configured as an action callback in a plugin. That action is then triggered by sending requests either through wp-admin/admin-ajax.php or admin-post.php. The first requires an AJAX request from jQuery, the latter accepts both GET and POST requests, no jQuery required.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using jQuery .load() function with wordpress and gravity forms’ is closed to new replies.