Skip to content

Instantly share code, notes, and snippets.

Created December 20, 2011 08:15
What would you like to do?
Gravity Forms API
// 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>' )
// Output buffering, cleaned up a bit later, makes sure there is no "ugliness" from WP plugins.
// 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.
if ( isset($_GET['debug']) ) {
header('Content-type: text/plain; charset=UTF-8');
} else {
header('Content-type: application/json; charset=UTF-8');
echo json_encode($leads);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment