Advertisement
designbymerovingi

daily point gain limit with buycred exception

Oct 15th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. add_filter( 'mycred_add', 'mycred_pro_global_daily_limit', 1, 3 );
  2. function mycred_pro_global_daily_limit( $reply, $request, $mycred ) {
  3.  
  4. if ( $reply === false || substr( $request['ref'], 0, 15 ) == 'buy_creds_with_' ) return $reply;
  5. $user_id = absint( $request['user_id'] );
  6.  
  7. // Get total for today starting from midnight til now
  8. $total = mycred_get_total_by_time( 'today', 'now', NULL, $user_id );
  9.  
  10. // If we have earned 20 points today decline everything else
  11. if ( $total >= 20 )
  12. return false;
  13.  
  14. return $reply;
  15.  
  16. // Exclude buyCred points gained regardless of the maximum points set from this snippet.
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement