add_filter( 'mycred_add', 'add_bonus_points_for_purchase', 10, 3 );
function add_bonus_points_for_purchase( $reply, $request, $mycred )
{
if ( $reply === false ) return $reply;
// For Stripe Payments
if ( $request['ref'] != 'buy_creds_with_stripe' ) {
$amount = $request['amount'];
// Award bonus for purchases over 9 points
if ( $amount == 10 ) {
// Give extra 2 points
// Remember not to use $mycred->add_creds() here or you will
// create an endless loop. Instead use update_users_balance()
$mycred->update_users_balance( $request['user_id'], 2 );
// Log the good news
$mycred->add_to_log(
'bonus_points',
$request['user_id'],
2,
'Bonus points for %plural% purchase!'
);
}
}
return $reply;
}
I also tried this (switching “==9” to “> 9”:
add_filter( 'mycred_add', 'add_bonus_points_for_purchase', 10, 3 );
function add_bonus_points_for_purchase( $reply, $request, $mycred )
{
if ( $reply === false ) return $reply;
// For Stripe Payments
if ( $request['ref'] != 'buy_creds_with_stripe' ) {
$amount = $request['amount'];
// Award bonus for purchases over 9 points
if ( $amount > 9 ) {
// Give extra 2 points
// Remember not to use $mycred->add_creds() here or you will
// create an endless loop. Instead use update_users_balance()
$mycred->update_users_balance( $request['user_id'], 2 );
// Log the good news
$mycred->add_to_log(
'bonus_points',
$request['user_id'],
2,
'Bonus points for %plural% purchase!'
);
}
}
return $reply;
}