Advertisement
designbymerovingi

adjust mycred transfer

Feb 19th, 2015
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. /**
  2.  * Adjust Transfers
  3.  * Will change the points to be charged for the transfer
  4.  * to the custom point type "my_custom_type" and deposit
  5.  * the same amount into the senders account in the original
  6.  * point type.
  7.  * @version 1.0
  8.  */
  9. add_filter( 'mycred_run_this', 'mycred_pro_payout_on_transfer', 10, 2 );
  10. function mycred_pro_payout_on_transfer( $request, $mycred ) {
  11.  
  12.     extract( $request );
  13.  
  14.     if ( $ref != 'transfer' || ( $ref == 'transfer' && $amount > 0 ) ) return $request;
  15.  
  16.     $request['type'] = 'my_custom_type';
  17.  
  18.     $mycred->update_balance( $user_id, $amount, $type );
  19.     $mycred->add_to_log(
  20.         $ref,
  21.         $user_id,
  22.         abs( $amount ),
  23.         $entry,
  24.         $ref_id,
  25.         $data,
  26.         $type
  27.     );
  28.  
  29.     return $request;
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement