A free points management plugin for WordPress.
myCRED Logo
myCRED Logo
  • Membership New
  • Chapters
    • Chapter I – Introduction
    • Chapter II – Getting Started
    • Chapter III – Add-ons
    • Chapter IV – Premium Add-ons
    • Chapter V – For Developers
    • Chapter VI – Reference Guides
  • Categories
    • Actions
    • Classes
    • Constants
    • Filters
    • Functions
    • Objects
    • Shortcodes
    • Hooks
    • Template Tags
  • Packages
    • mycred/api
    • mycred/badge
    • mycred/balance
    • mycred/banking
    • mycred/content
    • mycred/core
    • mycred/coupon
    • mycred/email
    • mycred/game
    • mycred/log
    • mycred/notice
    • mycred/payment
    • mycred/purchase
    • mycred/rank
    • mycred/transfer
  • Store
  • Download
    Navigation
    • Loading navigation ...
    All Shortcodes
    myCRED shortcodes
    1. mycred_affiliate_id
    2. mycred_affiliate_link
    3. mycred_all_scratch_cards
    4. mycred_badges
    5. mycred_badges_list
    6. mycred_badges_progress
    7. mycred_best_user
    8. mycred_buy
    9. mycred_buy_form
    10. mycred_buy_pending
    11. mycred_cashcred
    12. mycred_chart_balance_history
    13. mycred_chart_circulation
    14. mycred_chart_gain_loss
    15. mycred_chart_history
    16. mycred_chart_instance_history
    17. mycred_chart_top_balances
    18. mycred_chart_top_instances
    19. mycred_content_buyer_avatars
    20. mycred_content_buyer_count
    21. mycred_content_sale_count
    22. mycred_email_subscriptions
    23. mycred_exchange
    24. mycred_give
    25. mycred_hide_if
    26. mycred_history
    27. mycred_hook_table
    28. mycred_leaderboard
    29. mycred_link
    30. mycred_list_ranks
    31. mycred_load_coupon
    32. mycred_lotteries
    33. mycred_lottery
    34. mycred_lottery_jackpot
    35. mycred_lottery_quickpick
    36. mycred_lottery_results
    37. mycred_lottery_winnings
    38. mycred_my_badges
    39. mycred_my_balance
    40. mycred_my_balance_converted
    41. mycred_my_rank
    42. mycred_my_ranking
    43. mycred_my_ranks
    44. mycred_my_ranks_progress
    45. mycred_my_transfer_fee
    46. mycred_paymentwall
    47. mycred_pending_transfers
    48. mycred_rank_progress
    49. mycred_referral_stats
    50. mycred_sales_history
    51. mycred_scratch_cards
    52. mycred_scratch_cards_remaining
    53. mycred_scratch_history
    54. mycred_sell_this
    55. mycred_sell_this_ajax
    56. mycred_send
    57. mycred_show_if
    58. mycred_stripe_buy
    59. mycred_stripe_subscribe
    60. mycred_stripe_subscription
    61. mycred_total_balance
    62. mycred_total_points
    63. mycred_total_since
    64. mycred_transfer
    65. mycred_users_of_all_ranks
    66. mycred_users_of_rank
    67. mycred_video
    Categories
    Filter by category
    1. Actions
    2. Classes
    3. Filters
    4. Functions
    5. Hooks
    6. Objects
    7. Shortcodes
    8. Template Tags
    Chapters
    Documentation
    1. Chapter I - Introduction
    2. Chapter II - Getting Started
    3. Chapter III - Add-ons
    4. Chapter IV - Premium Add-ons
    5. Chapter V - For Developers
    6. Chapter VI - Reference Guides
mycred_best_user

Codex / mycred/balance / Shortcodes / mycred_best_user

Description

This shortcode allows you to present the “best” user according to their total accumulated balance or by one or more references. The shortcode by default shows the users name and avatar but this can be customized to show the details you want.

The shortcode will present by default the users avatar and display name, but this can be customized by wrapping the shortcode around custom HTML. See below for available template tags you can use.

Available since version 1.6.7

Shortcode Attributes
Attribute Type Required Default Description
ref string No - Optional reference(s) to base the best user of. Can either be one particular reference or a comma separated list of references.
from string No - Optional date from when log entries should be calculated. Can be either a well formatted date or keywords like "now" or "today". See strtotime for further information on available options.
until string No - Used in combination with "from" the end date of calculations. Can be either a well formatted date or keywords like "now" or "today". See strtotime for further information on available options.
types string No mycred_default Option to limit calculation to a particular point type or a comma separated list of point types.
nothing string No "No user found" Text to show if no user was found to be the best based on your shortcode setup.
order string No DESC The sort order to use in calculations. Can either be "DESC" for descending or "ASC" for ascending.
avatar int No 50 The size of the avatar image without "px".
CSS Styling
.mycred-best-user { }
.mycred-best-user-no-results { }
Available Template Tags
  • %display_name% – replaced with the users display name
  • %first_name% – replaced with the users first name
  • %last_name% – replaced with the users last name
  • %user_email% – replaced with the users email
  • %user_login% – replaced with the users username
  • %avatar% – replaced with the users avatar
  • %total% – replaced with the total calculated points amount
  • %total_abs% – replaced with the total calculated points amount and converted it into a positive number. Use this if you add up negative values but want to show a positive value.
  • %count% – replaced with the total count of log entries found for this result
Examples

Example 1: Show the best user based on who has received most points for approved comments.

[mycred_best_user ref="approved_comment"]

Example 2: Show the user who has gained most points from January 1st 2014 until now. Will calculate all instances no matter what point types there exist.

[mycred_best_user from="2016-01-01" until="now"]

Example 3: Show the user who has spent most points in the store. Note that purchases are stored as a negative value which means we need to reverse the order or the user who spent least will show up.

[mycred_best_user ref="woocommerce_payment" order="ASC"]

Example 4: Show the user who has gained most points from the default point type and a custom point type.

[mycred_best_user types="mycred_default,customtypekey"]

Example 5: Show the user who has gained most points no matter which point type is used, and adjust the template to only show their avatar and nothing else.

[mycred_best_user]
<div class="mycred-best-user text-center">%avatar%</div>
[/mycred_best_user]

About myCRED

myCRED is a free, open-source and developer friendly points management tool for WordPress powered websites.

Download Rate Plugin

Documentation

  • Add-ons
  • Core Shortcodes
  • F.A.Q.
  • Tutorials
  • Third Party Plugins
  • Code Snippets

Support

  • Product Licenses
  • Customization
  • Support Forums
  • Plugin Changelog
  • Contact

Copyright 2013 - 2022 byWPExperts; All rights reserved. myCRED is licensed under GPL 2.0

Terms & Conditions • Use of Cookies • Store Policy • Community Rules

Suggest Codex Example

You can submit suggestions for codex examples that you have available as a public gist. If you are a member on the mycred.me website, you can earn Tokens for each submission. To claim these Tokens, make sure you provide your mycred.me username.

Please make sure the example you submit is relevant and if you include documentation, it's provided in English.

logo
  • Membership New
  • Chapters
    • Chapter I – Introduction
    • Chapter II – Getting Started
    • Chapter III – Add-ons
    • Chapter IV – Premium Add-ons
    • Chapter V – For Developers
    • Chapter VI – Reference Guides
  • Categories
    • Actions
    • Classes
    • Constants
    • Filters
    • Functions
    • Objects
    • Shortcodes
    • Hooks
    • Template Tags
  • Packages
    • mycred/api
    • mycred/badge
    • mycred/balance
    • mycred/banking
    • mycred/content
    • mycred/core
    • mycred/coupon
    • mycred/email
    • mycred/game
    • mycred/log
    • mycred/notice
    • mycred/payment
    • mycred/purchase
    • mycred/rank
    • mycred/transfer
  • Store
  • Download