<?php
/**
* Retrieve all the Gravity Forms submissions made by the current user for a given form.
*
* @param int $form_id The ID of the Gravity Form to retrieve submissions for.
*
* @return string A HTML table containing the submissions.
*
* @example [gf_user_entries form_id="1"]
*
*/
function gf_display_user_entries( $form_id ) {
if ( ! is_user_logged_in() ) {
return '<p>You must be logged in to view your submissions.</p>';
}
$user_id = get_current_user_id();
$entries = GFAPI::get_entries( $form_id, array(
'field_filters' => array(
array(
'key' => 'created_by',
'value' => $user_id
)
)
) );
if ( empty( $entries ) ) {
return '<p>No submissions found.</p>';
}
// Get the form fields to use as table headers
$form = GFAPI::get_form( $form_id );
$fields = $form['fields'];
$output = '<table class="gf-entries-table">';
$output .= '<thead><tr>';
// Table Headers
$output .= '<th>Entry ID</th><th>Submission Date</th>';
foreach ( $fields as $field ) {
if ( ! empty( $field->label ) ) {
$output .= '<th>' . esc_html( $field->label ) . '</th>';
}
}
$output .= '</tr></thead><tbody>';
// Table Body
foreach ( $entries as $entry ) {
$output .= '<tr>';
$output .= '<td>' . esc_html( $entry['id'] ) . '</td>';
$output .= '<td>' . esc_html( date( 'F j, Y', strtotime( $entry['date_created'] ) ) ) . '</td>';
foreach ( $fields as $field ) {
if ( ! empty( $field->id ) ) {
$field_value = isset( $entry[ $field->id ] ) ? $entry[ $field->id ] : '-';
$output .= '<td>' . esc_html( $field_value ) . '</td>';
}
}
$output .= '</tr>';
}
$output .= '</tbody></table>';
return $output;
}
// Create a Shortcode
add_shortcode( 'gf_user_entries', function( $atts ) {
$atts = shortcode_atts( array(
'form_id' => 1
), $atts );
return gf_display_user_entries( $atts['form_id'] );
} );PHPHow to use this snippet?
Add this snippet to your child theme’s functions.php file or a custom plugin.
Then insert the shortcode on any page:
[gf_user_entries form_id="1"]PHPReplace 1 with your actual Gravity Forms ID.
Only the logged-in user will see their own submissions, displayed in a structured table with all fields included.
Optional Styling (Recommended)
For a cleaner table layout, add the following CSS to your site:
.gf-entries-table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
font-size: 14px;
}
.gf-entries-table th, .gf-entries-table td {
border: 1px solid #ddd;
padding: 10px;
text-align: left;
}
.gf-entries-table th {
background-color: #f4f4f4;
font-weight: bold;
}
.gf-entries-table tr:nth-child(even) {
background-color: #f9f9f9;
}
.gf-entries-table tr:hover {
background-color: #f1f1f1;
transition: 0.3s;
}
CSS