Advertisement
designbymerovingi

Award bonus points of a custom point type for content purcha

Aug 12th, 2014
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. add_filter( 'mycred_add', 'award_point_type_for_content_purchase', 90, 3 );
  2. function award_point_type_for_content_purchase( $reply, $request, $mycred ) {
  3.  
  4.     // Only applicable for content purchases and not profit share payouts
  5.     if ( $reply === false || $request['ref'] != 'buy_content' || $request['amount'] > 0 ) return $reply;
  6.  
  7.     // The bonus point type and amount
  8.     $bonus_type = 'mytype';
  9.     $bonus = 10;
  10.  
  11.     // Payout the bonus
  12.     $mycred->update_users_balance( $request['user_id'], $bonus, $bonus_type );
  13.  
  14.     // Log the bonus
  15.     $mycred->add_to_log(
  16.         $request['ref'],
  17.         $request['user_id'],
  18.         $bonus,
  19.         'Bonus %plural% for content purchase',
  20.         $request['ref_id'],
  21.         $request['data'],
  22.         $bonus_type
  23.     );
  24.  
  25.     return $reply;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement