Description
The gravityflow_sort_criteria_status filter allows the initial sort order on status page load to be defined.
Parameters
Parameter | Type | Details |
---|---|---|
$sorting_criteria | Array | The sort criteria for the status page. |
Examples
Change the default sort to match based on a custom meta column
A custom meta column, defined through gform_entry_meta, would also use gravityflow_columns_status_table to display the custom column, gravityflow_field_value_status_table to display the custom meta value in the column, along with gravityflow_sort_columns_status_table to define that column
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | add_filter( 'gravityflow_sort_criteria_status' , 'sort_criteria_status' ); function sort_criteria_status( $sort_criteria ) { //Adjust to only have the default filter execute on your desired page(s) if ( ! is_page( '94' ) ) { return $sort_criteria ; } //Ensure that if the user has clicked on a sort column header this filter won't override that if ( ! rgget( 'orderby' ) && ! rgget( 'order' ) ) { //Modify the key attribute to match the field/custom column you wish to sort by. $sort_criteria [ 'key' ] = 'priority' ; $sort_criteria [ 'direction' ] = 'DESC' ; $sort_criteria [ 'is_numeric' ] = true; } return $sort_criteria ; } |
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?