Skip to content

Instantly share code, notes, and snippets.

@jdevalk
Created December 20, 2011 08:15
Show Gist options
  • Save jdevalk/1500757 to your computer and use it in GitHub Desktop.
Save jdevalk/1500757 to your computer and use it in GitHub Desktop.
Gravity Forms API
<?php
// Add a search to filter the entires, the form_id is the form ID you see in the GET variable on the entries or edit page
$search = "";
$form_id = 4;
// Authentication (add a username if you want for more security)
if ( ! isset($_GET['key']) || $_GET['key'] != '<set an API Key>' )
die;
// Output buffering, cleaned up a bit later, makes sure there is no "ugliness" from WP plugins.
ob_start();
// Make sure this points to wp-load.php, I usually keep this in root but you can use it anywhere
require './wp-load.php';
// This function is in the forms model file, should you wish to look it up and adapt it
$leads = RGFormsModel::get_leads($form_id, 'id', "DESC", $search, 0, 20, null, null, true, null, null, "active");
// Drop all the output generated so far as it can basically only be crap fron plugins.
ob_end_clean();
if ( isset($_GET['debug']) ) {
header('Content-type: text/plain; charset=UTF-8');
print_r($leads);
} else {
header('Content-type: application/json; charset=UTF-8');
echo json_encode($leads);
}
die;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment