Get Total Paid by Email

Use this helper function to get the total paid across all forms for a email address.

Example:

$total = gw_get_total_by_email( ‘dave@smiff.com’ );

Code

Filename: gw-get-total-paid-by-email.php

<?php
/**
 * Gravity Wiz // Gravity Forms // Get Total Paid by Email
 * https://gravitywiz.com/
 *
 * Use this helper function to get the total paid across all forms for a email address.
 *
 * Example:
 *
 * $total = gw_get_total_by_email( 'dave@smiff.com' );
 */
function gw_get_total_by_email( $email, $form_ids = null ) {
	$entries = gfapi::get_entries( $form_ids, array(
		'field_filters' => array(
			array( 'value' => $email ),
			array(
				'key'   => 'payment_status',
				'value' => 'paid',
			),
		),
	) );
	$total   = 0;
	foreach ( $entries as $entry ) {
		$total += floatval( $entry['payment_amount'] );
	}
	return $total;
}

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.