Last active
October 13, 2018 06:08
-
-
Save vince844/980904182e98cd1519f96dc1b655db71 to your computer and use it in GitHub Desktop.
MyCred update user points on Gravity Form submission
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
add_action( 'gform_after_submission_1', 'karibusana_update_mycred_user_balance', 10, 2 ); // Change 1 with the form ID | |
function karibusana_update_mycred_user_balance ($entry, $form) { | |
// Change 23 to the ID of the form field you want | |
$orderID = rgar($entry, '23'); | |
$user_id = get_current_user_id(); | |
// switch to mycred_add if you want to add points instead of subtract | |
if (function_exists('mycred_subtract')) { | |
mycred_subtract( | |
'Riduzione punti per invio form', | |
$user_id, | |
$orderID, | |
'Totale Punti: ' . $orderID | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this function is not subtracting the balance