Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active October 22, 2018 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/7d5e3bbe9751a3c391c0e4ff6c93db4f to your computer and use it in GitHub Desktop.
Save cliffordp/7d5e3bbe9751a3c391c0e4ff6c93db4f to your computer and use it in GitHub Desktop.
Get a count of Gravity Forms entries in October 2018 that are not trashed that were not created by an Administrator
<?php
$admin_users = get_users( [ 'role' => 'administrator' ] );
$admin_user_ids = wp_list_pluck( $admin_users, 'ID' );
$entries_search = [
'status' => 'active', // non-trashed entries
'start_date' => '2018-10-01 00:00:00', // October 1
'end_date' => '2018-10-31 23:59:59', // October 31
'field_filters' => [
[
'key' => 5, // Field ID 5
'value' => 277, // Entry value
'operator' => '=',
],
// entry not created by an Administrator
[
'key' => 'created_by',
'value' => $admin_user_ids,
'operator' => 'NOT IN',
],
],
];
$used = GFAPI::count_entries( 3, $entries_search );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment