Table of Contents
Overview
The request from an established medical charity was to create a tailored event-based application. The application needed to provide for easy upkeep by essentially untrained staff, alongside open, continual, collaborative customization with the developer (me) and the designer.
Variations on this application have now been used by this organization three times, at cumulative savings – or enhanced charitable proceeds – of tens of thousands of dollars compared to deployment of the most widely used premium applications used by charities.
Front End (User Experience)
Back End - Staff Interface
Back End - Developer Actions
Code Highlights
The chief requirements for custom coding on this application were for
- Adding Advanced Custom Field output as well as shortcodes using ACF outputs to an Event page in ELementor and to Elementor custom post templates.
- Integrating Gravity Form submission with Advanced Custom Field updates,
- Limited Reconciliation of Successful vs Failed vs External Donations, facilitated via Gravity Forms API (GFAPI) methods.
Shortcodes
'teams',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
'fields' => 'ids',
'category__not_in' => array( 54 )
) ;
$team_ids = get_posts( $args ) ;
ob_start() ;
?>
Raised so far: $' . number_format( $raised, 2 ) ;
}
return 'Raised so far: $' . number_format( 0, 2 ) ;
}
add_shortcode( 'dcf_get_team_fundraising_goal', 'dcf_get_team_fundraising_goal' ) ;
function dcf_get_team_fundraising_goal() {
$post_id = get_the_ID() ;
$goal = get_field( 'field_6849f5dbc3cea', $post_id ) ;
if ( $goal ) {
return 'Goal: $' . number_format( $goal, 2 ) ;
}
return '$' . number_format( 0, 2 ) ;
}
Gravity Form Filter Functions
id == 46 ) {
$choices = $field['choices'] ;
foreach ( $choices as $key => $value ) {
if ( $value['value'] == get_the_ID() ) {
$value['isSelected'] = true ;
$choices[$key] = $value ;
}
}
$field->choices = $choices ;
}
}
return $form ;
}
/**
* Using Gravity Forms "Advanced Post Creation Add-On," update specific Advanced Custom Fields values and also clear WPRocket cache so that users view fresh content
*/
/**
* ADVANCED POST CREATION
*/
add_action( 'gform_advancedpostcreation_post_after_creation_55', 'pepp_team_creation_add_key_values', 9, 4 );
function pepp_team_creation_add_key_values( $team_id, $feed, $entry, $form ) {
$captain = rgar( $entry, '3.3' ) . ' ' . rgar( $entry, '3.6' ) ;
$goal = rgar( $entry, '10' ) ;
$new_amount = absint( rgar( $entry, '13' ) ) ;
//DEBUGGING
$form_id = $form['id'] ;
update_field( 'field_6849f480d3a9b', $new_amount, $team_id ) ; //"end," raised so far
update_field( 'field_6849f5dbc3cea', $goal, $team_id ) ; //goal
update_field( 'field_6851fc9e856d8', $captain, $team_id ) ; //captain
update_field( 'field_685349240f485', $captain, $team_id ) ; //roster
$old_amount = get_field( 'pepp_raised_so_far', 5382 ) ;
$new_total = $new_amount + $old_amount ;
update_field( 'pepp_raised_so_far', $new_total, 5382 ) ;
//clear WP Rocket Cache for PEPP 2025
if ( function_exists( 'rocket_clean_post' ) ) {
$cleaned = rocket_clean_post( 5382 ) ;
$cleaned = rocket_clean_post( $team_id ) ;
}
}
/**
* Add Member to Team on "Team Join" Submission
*/
add_action( 'gform_after_submission_54', 'pepp_team_join_add_member', 10, 2 ) ;
function pepp_team_join_add_member( $entry, $form ) {
$team_id = rgar( $entry, '46' ) ;
//add member name
$member_name = trim( rgar( $entry, '2.3' ) . ' ' . rgar( $entry, '2.6' ) ) ;
$current_members = get_field( 'team_roster', $team_id ) ;
$members_array = array_map( 'trim', explode( ',', $current_members ) ) ;
if ( ! in_array( $member_name, $members_array ) ) {
$current_members = $current_members . ', ' . $member_name ;
}
update_field( 'team_roster', $current_members, $team_id ) ;
//clear WP Rocket Cache for Team Post
if ( function_exists( 'rocket_clean_post' ) ) {
$cleaned = rocket_clean_post( $team_id ) ;
}
}
/**
* Updated campaign totals after team creation, team join, or direct donation
* Use Gravity Forms API to log donations and reconcile totals if desired
*/
add_action( 'gform_after_submission', 'pepp_2025_update_total_raised', 10, 2 ) ;
function pepp_2025_update_total_raised( $entry, $form ) {
$form_id = $form['id'] ;
$team_id = 0 ;
//prior array( '31', '32', '33' ) ) ) { //individual registration, team join
if ( in_array( $form_id, array( '52', '54', '51' ) ) ) { //individual registration, team join, donation
/** GET DATA FOR DEBUGGING AND RECONCILIATION
custom_log( __FUNCTION__ ) ;
custom_log( GFAPI::get_entries( $form_id, array( 'status' => 'active' ), array(), array( 'offset'=> 0, 'page_size' => 200 ) ) ) ;
**/
$new_amount = rgar( $entry, '22' ) ;
$old_amount = get_field( 'pepp_raised_so_far', 5382 ) ;
$new_total = $old_amount + $new_amount ;
/**
custom_log( 'OLD AMOUNT: ' . $old_amount ) ;
custom_log( 'NEW AMOUNT: ' . $new_amount ) ;
custom_log( 'NEW TOTAL: ' . $new_total ) ;
**/
update_field( 'pepp_raised_so_far', $new_total, 5382 ) ;
if ( '54' == $form_id || '51' == $form_id ) {
$team_id = rgar( $entry, '46' ) ;
}
if ( $team_id ) {
$old_team_total = get_field( 'team_end', $team_id ) ;
$new_team_total = $old_team_total + $new_amount ;
update_field( 'team_end', $new_team_total, $team_id ) ;
}
//clear WP Rocket Cache for PEPP 2025
if ( function_exists( 'rocket_clean_post' ) ) {
rocket_clean_post( 5382 ) ;
}
}
}



