Display Gravity Forms Entries for the Logged-In User

If you’re using Gravity Forms for user submissions, surveys, registrations, or custom dashboards, you may want to show each user only their own form submissions on the frontend. This snippet retrieves and displays all entries submitted by the currently logged-in user for a specific form ID. It’s perfect for user dashboards, membership sites, LMS setups, portals, or account pages where users need to view their past submissions.

<?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'] );
} );
PHP

How 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"]
PHP

Replace 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

Usage:

The snippet retrieves and displays all entries submitted by the currently logged-in user for a specific form ID.

Benefits:

  • Private User Dashboard – Show users only their own entries.
  • Perfect for Membership Sites – Useful for student dashboards, job submissions, quizzes, registrations, etc.
  • Cleaner Data Display – Automatically loops all form fields inside a clean table.
  • Shortcode-Based – Easy to embed anywhere (Elementor, Gutenberg, custom templates).

Frequently Asked Questions

Yes. In the loop that generates table cells, simply add a condition to skip specific field IDs.
Yes, but uploaded files will appear as URLs. You can convert them into clickable links by adjusting the output formatting.
Yes. You can add multiple shortcodes on different pages, each showing entries from different form IDs.

Related Links

Related Snippets

Hide WooCommerce Prices for Non-Logged-In Users
Hide WooCommerce product prices for visitors who aren’t logged in. It will encourage users to...
Disable WordPress Emoji Script Site-Wide
Disables WordPress emoji script site-wide to improve performance....
Picture of Kishan D
Kishan D
I’m a web developer who builds with WordPress, WooCommerce, and Shopify, and I enjoy exploring React and creating gaming & tech content.

SHARE POST

Leave a Reply