Advertisement
designbymerovingi

custom balance example shortcode

Nov 11th, 2016
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. /**
  2. * Shortcode: my_point_balance
  3. * @version 1.0
  4. */
  5. function mycred_pro_show_users_balance( $atts ) {
  6.  
  7. if ( ! is_user_logged_in() || ! function_exists( 'mycred' ) ) return;
  8.  
  9. extract( shortcode_atts( array(
  10. 'type' => 'mycred_default'
  11. ), $atts ) );
  12.  
  13. $mycred = mycred( $type );
  14. $user_id = get_current_user_id();
  15.  
  16. $output = '';
  17. if ( ! $mycred->exclude_user( $user_id ) ) {
  18. $balance = $mycred->get_users_balance( $user_id );
  19. $output = intval( $balance );
  20. }
  21.  
  22. return number_format( $output, 0, '.', '.' );
  23.  
  24. }
  25. add_shortcode( 'my_point_balance', 'mycred_pro_show_users_balance' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement