Advertisement
designbymerovingi

Send Email Notice if balance goes below 100 points

Jan 7th, 2015
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. /**
  2. * Add custom email instance
  3. * @for myCRED Email Notifications
  4. * @version 1.0
  5. */
  6. add_filter( 'mycred_email_instances', 'mycred_pro_add_custom_email_instance' );
  7. function mycred_pro_add_custom_email_instance( $instances ) {
  8.  
  9. // Custom instance with id "balance" (must be unique)
  10. $instances['less'] = array(
  11. 'label' => 'Balance',
  12. 'then' => 'balance is less then 100',
  13. 'end' => ''
  14. );
  15. return $instances;
  16.  
  17. }
  18.  
  19. /**
  20. * Handle custom email event
  21. * @for myCRED Email Notifications
  22. * @version 1.0
  23. */
  24. add_filter( 'mycred_get_email_events', 'mycred_pro_handle_custom_email_event', 10, 3 );
  25. function mycred_pro_handle_custom_email_event( $events, $request, $mycred ) {
  26.  
  27. if ( $request['amount'] < 0 ) {
  28.  
  29. extract( $request );
  30.  
  31. // The limit - change to any amount you like
  32. $limit = 100;
  33.  
  34. $balance = $mycred->get_users_balance( $user_id, $mycred->cred_id );
  35. if ( $balance < $limit )
  36. $events[] = 'less|then';
  37.  
  38. }
  39.  
  40. return $events;
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement