Gravity Forms Submissions DataTable

This WordPress plugin introduces a shortcode that leverages jQuery DataTables to present Gravity Forms submissions on your website. It's a useful tool for site administrators to display form entries in an organized, searchable, and sortable table. The plugin also takes care of loading necessary DataTables scripts and styles.

<?php /** * Plugin Name: Display GF Submissions * Plugin URI: * Description: This plugin adds a shortcode that displays Gravity Forms submissions on the frontend using jQuery DataTables. * Version: 1.0 * Author: CodeWP Assistant * Author URI: */ // Make sure to replace 'form_id' with your actual Gravity Forms form ID function display_gf_submissions_shortcode($atts) { $atts = shortcode_atts( [ "form_id" => "", ], $atts, "display_gf_submissions" ); if (!class_exists("GFAPI") || empty($atts["form_id"])) { return "Gravity Forms not found or form_id not specified!"; } $entries = GFAPI::get_entries($atts["form_id"]); if (is_wp_error($entries)) { return "Failed to get entries!"; } ob_start(); echo '<table id="gf-submissions-table">'; echo "<thead><tr>"; foreach ($entries[0] as $key => $value) { echo "<th>" . esc_html($key) . "</th>"; } echo "</tr></thead>"; echo "<tbody>"; foreach ($entries as $entry) { echo "<tr>"; foreach ($entry as $key => $value) { echo "<td>" . esc_html($value) . "</td>"; } echo "</tr>"; } echo "</tbody>"; echo "</table>"; echo '<script> jQuery(document).ready(function() { jQuery("#gf-submissions-table").dataTable({ "sScrollX": "100%", "sScrollXInner": "110%", }); }); </script>'; return ob_get_clean(); } add_shortcode("display_gf_submissions", "display_gf_submissions_shortcode"); function enqueue_datatables_scripts() { wp_enqueue_script( "datatables-js", "", ["jquery"], null, true ); wp_enqueue_style( "datatables-css", "" ); } add_action("wp_enqueue_scripts", "enqueue_datatables_scripts");

Frequently Asked Questions

The shortcode displays a table of Gravity Forms submissions on the front end of your WordPress site using jQuery DataTables.