Default Form List to Active Forms

Sets Form List view to Active Forms by Default.

Code

Filename: gw-form-list-active-by-default.php

<?php
/**
 * Gravity Wiz // Gravity Forms // Default Form List to Active Forms
 *
 * Sets Form List view to Active Forms by Default.
 *
 * @version 0.1
 * @author  David Smith <david@gravitywiz.com>
 * @license GPL-2.0+
 * @link    https://gravitywiz.com
 *
 * Plugin Name: Gravity Forms Default Form List to Active
 * Plugin URI: https://gravitywiz.com
 * Description: Sets Form List view to Active Forms by Default.
 * Author: Gravity Wiz
 * Version: 0.1
 * Author URI: https://gravitywiz.com
 *
 */
add_action( 'init', function() {
	if ( ! class_exists( 'GFForms' ) ) {
		return;
	}
	if ( GFForms::get_page() === 'form_list' ) {

		$params = array();

		if ( ! isset( $_GET['sort'] ) ) {
			$params = array(
				'sort'    => 'id',
				'dir'     => 'desc',
				'orderby' => 'id',
				'order'   => 'desc',
			);
		}

		if ( ! isset( $_GET['filter'] ) ) {
			$params['filter'] = 'active';
		}

		if ( ! empty( $params ) ) {
			wp_redirect( add_query_arg( $params ) );
			exit;
		}
	}

} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.