Advertisement
Guest User

Already I have

a guest
Mar 4th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. // SHOW TOTAL ON USERS PAGE - START
  2.  
  3.  
  4. $total = 0;
  5. if ( function_exists( 'mycred_get_types' ) ) {
  6. $types = mycred_get_types();
  7. foreach ( $types as $type_id => $label ) {
  8. $balance = get_user_meta( $user_id, $type_id, true );
  9. if ( $balance == '' ) continue;
  10. $total = $total + $balance;
  11. }
  12. }
  13.  
  14. // Add in the custom column
  15. add_filter('manage_users_columns', 'mycred_pro_add_custom_user_column');
  16. function mycred_pro_add_custom_user_column($columns) {
  17. $columns['mycred-total-all'] = 'Total Cashback';
  18. return $columns;
  19. }
  20.  
  21. // Add the custom columns content
  22. add_action('manage_users_custom_column', 'mycred_pro_show_custom_user_column', 10, 3);
  23. function mycred_pro_show_custom_user_column($value, $column_name, $user_id) {
  24.  
  25. if ( 'mycred-total-all' == $column_name ) {
  26. $total = 0;
  27. if ( function_exists( 'mycred_get_types' ) ) {
  28. $types = mycred_get_types();
  29. foreach ( $types as $type_id => $label ) {
  30. $balance = get_user_meta( $user_id, $type_id, true );
  31. if ( $balance == '' ) continue;
  32. $total = $total + $balance;
  33. }
  34. }
  35. $value = "₹ ".number_format( $total, 2, '.', ',' );
  36. }
  37. return $value;
  38. }
  39.  
  40. // FORMAT TOTAL OUTPUT IN FRONT-END -START
  41.  
  42. add_filter( 'mycred_total_balances_output', 'mycred_pro_format_total_shortocode' );
  43. function mycred_pro_format_total_shortocode( $total ) {
  44.  
  45. return number_format( $total, 2, '.', ',' );
  46.  
  47. }
  48.  
  49. // FORMAT TOTAL OUTPUT IN FRONT-END - END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement