Limit by Approved Entries Only

When using GravityView, only count “Approved” entries towards the inventory limit.

Code

Filename: gpi-limit-by-approved-entries-only.php

<?php
/**
 * Gravity Perks // Inventory // Limit by Approved Entries Only
 * https://gravitywiz.com/documentation/gravity-forms-inventory/
 *
 * When using GravityView, only count "Approved" entries towards the inventory limit.
 */
add_filter( 'gpi_query', function( $query ) {
	global $wpdb;

	$query['join']  .= ' INNER JOIN wp_gf_entry_meta emgv ON emgv.entry_id = em.entry_id ';
	$query['where'] .= ' AND emgv.meta_key = "is_approved" AND emgv.meta_value = "1" ';

	return $query;
} );

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.