Description
The gravityflow_search_criteria_status is used to allow search_criteria to be adjusted for which entries are displayed in the status table. The criteria following the parameter structure is defined by the Gravity Forms API for get_entries. If you are looking to customize the search_criteria for multiple forms refer to the gravityflow_form_ids_status filter as well.
Parameters
Parameter | Type | Details |
---|---|---|
$criteria | Array | The search criteria |
Examples
Limit entries to those created by an administrator
add_filter( 'gravityflow_search_criteria_status', 'sh_status_search_criteria', 10, 1 );
function sh_status_search_criteria( $search_criteria ) {
//Add appropriate checks to confirm the status page/shortcode you are adjusting.
//Without it, all status pages will be filtered by your condition.
//Define user query for admins
$user_query = new WP_User_Query( array( 'role' => 'Administrator' ) );
$admins = $user_query->get_results();
// Check for results
if ( ! empty( $admins ) ) {
$admin_ids = array();
// loop through each author
foreach ( $admins as $admin ) {
$admin_ids[] = $admin->ID;
}
//Add search criteria - See https://docs.gravityforms.com/api-functions/#get-entries
$search_criteria['field_filters'][] = array( 'key' => 'created_by', 'operator' => 'in', 'value' => $admin_ids );
}
return $search_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?