Last active
August 23, 2017 00:05
-
-
Save joshuaiz/b7cfbe4d56220555d397319413feae9e to your computer and use it in GitHub Desktop.
Trying to save GF donation amount to ACF custom user field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action("gform_after_submission_6", "update_usar_sponsorship_amount", 10, 2); | |
function update_usar_sponsorship_amount($entry, $form) { | |
// get required GF fields | |
$team = rgar( $entry, "14"); // GF radio buttons (select Team to sponsor) | |
$amount = rgar($entry, "2"); // donation amount | |
// query through users | |
$users = get_users(); | |
// loop through users | |
foreach ( $users as $user ) { | |
$userteam = $user->display_name; | |
$currentAmount = $user->sponsorship_amount; | |
// $amount = $currentAmount + $amount; // this doesn't work because $amount isn't a number | |
// if selected Team name matches user display name, update that user | |
if ( $userteam == $team ) { | |
update_user_meta( $user->ID, 'sponsorship_amount', $amount ); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment