Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SHOW TOTAL ON USERS PAGE - START
- $total = 0;
- if ( function_exists( 'mycred_get_types' ) ) {
- $types = mycred_get_types();
- foreach ( $types as $type_id => $label ) {
- $balance = get_user_meta( $user_id, $type_id, true );
- if ( $balance == '' ) continue;
- $total = $total + $balance;
- }
- }
- // Add in the custom column
- add_filter('manage_users_columns', 'mycred_pro_add_custom_user_column');
- function mycred_pro_add_custom_user_column($columns) {
- $columns['mycred-total-all'] = 'Total Cashback';
- return $columns;
- }
- // Add the custom columns content
- add_action('manage_users_custom_column', 'mycred_pro_show_custom_user_column', 10, 3);
- function mycred_pro_show_custom_user_column($value, $column_name, $user_id) {
- if ( 'mycred-total-all' == $column_name ) {
- $total = 0;
- if ( function_exists( 'mycred_get_types' ) ) {
- $types = mycred_get_types();
- foreach ( $types as $type_id => $label ) {
- $balance = get_user_meta( $user_id, $type_id, true );
- if ( $balance == '' ) continue;
- $total = $total + $balance;
- }
- }
- $value = "₹ ".number_format( $total, 2, '.', ',' );
- }
- return $value;
- }
- // FORMAT TOTAL OUTPUT IN FRONT-END -START
- add_filter( 'mycred_total_balances_output', 'mycred_pro_format_total_shortocode' );
- function mycred_pro_format_total_shortocode( $total ) {
- return number_format( $total, 2, '.', ',' );
- }
- // FORMAT TOTAL OUTPUT IN FRONT-END - END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement