Skip to content

Commit a7e5f0b

Browse files
authored
gw-get-total-paid-by-email.php: Added new snippet.
1 parent 50d3fac commit a7e5f0b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Gravity Wiz // Gravity Forms // Get Total Paid by Email
4+
* https://gravitywiz.com/
5+
*
6+
* Use this helper function to get the total paid across all forms for a email address.
7+
*
8+
* Example:
9+
*
10+
* $total = gw_get_total_by_email( '[email protected]' );
11+
*/
12+
function gw_get_total_by_email( $email, $form_ids = null ) {
13+
$entries = gfapi::get_entries( $form_ids, array(
14+
'field_filters' => array(
15+
array( 'value' => $email ),
16+
array( 'key' => 'payment_status', 'value' => 'paid' )
17+
)
18+
) );
19+
$total = 0;
20+
foreach ( $entries as $entry ) {
21+
$total += floatval( $entry['payment_amount'] );
22+
}
23+
return $total;
24+
}

0 commit comments

Comments
 (0)