Order form list table by most recent

This feature is now available within the Gravity Hopper plugin.

It can be handy, especially during development, to have your most recent forms (those likely under active development) listed first in your form table. This snippet will allow you to set the default sort order to most recent.

// Order form list table by most recent
add_filter( 'gform_form_list_forms', function( $forms, $search_query, $active, $sort_column, $sort_direction, $trash ) {

    if ( ! rgget( 'orderby' ) ) {

        usort( $forms, function( $a, $b ) {
            return $b->id <=> $a->id;
        } );

    }

    return $forms;

}, 10, 6 );Code language: PHP (php)

How do you find this article?