Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuaiz/b7cfbe4d56220555d397319413feae9e to your computer and use it in GitHub Desktop.
Save joshuaiz/b7cfbe4d56220555d397319413feae9e to your computer and use it in GitHub Desktop.
Trying to save GF donation amount to ACF custom user field
<?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