A free points management plugin for WordPress.
myCRED Logo
myCRED Logo
  • 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
Chapter I
Introduction
  1. The Plugin
  2. Points
  3. The Log
  4. Administration
  5. Automatic Points
  6. Multisites
    • Master Template
    • Central Logging
  7. Add-ons
  8. Supported Plugins
  9. BuddyPress
  10. Usage Examples
  11. Limitations
Chapter II
Getting Started
  1. Installation
  2. Point Type Settings
  3. Multiple Point Types
  4. Adjusting Balances
  5. Setup Hooks
  6. Import Data
    • Importing Balances
    • Importing Log Entries
    • Import CubePoints
  7. Export Data
  8. Widgets
  9. Shortcodes
  10. Optimization
  11. Uninstall
Chapter III
Add-ons
  1. Badges
    • Creating Badges
    • Manual Badges
    • Displaying Badges
    • Developer Resources
  2. Banking
    • Central Banking
    • Compound Interest
    • Recurring Payout
    • Developer Resources
  3. buyCRED
    • Selling Points
    • Add-on Setup
    • Payment Gateways
    • The Checkout Page
    • Pending Payments
    • Developer Resources
  4. Coupons
    • Creating Coupons
    • Redeeming Coupons
    • Coupon Management
    • Developer Resources
  5. Email Notifications
    • Add-on Setup
    • Creating Emails
    • Unsubscribe
    • Developer Resources
  6. Gateway
    • WooCommerce
    • WP E-Commerce
    • Event Espresso
    • Events Manager
    • Developer Resources
  7. Notifications
    • Troubleshooting
    • Developer Resources
  8. Ranks
    • Introduction
    • Add-on Setup
    • Create New Rank
    • Displaying Ranks
    • Developer Resources
  9. Sell Content
    • Add-on Setup
    • Manual Mode
    • Available Shortcodes
    • Troubleshooting
    • Developer Resources
  10. Statistics
  11. Transfers
    • Add-on Setup
    • Available Shortcodes
    • Transfer Messages
    • Transfer Types
    • Developer Resources
Chapter IV
Premium Add-ons
  1. The myCRED Store
  2. buyCRED Gateways
    • Stripe
    • Payza
    • Wepay
    • PayFast
    • 2checkout
    • Coinbase
    • ComproPago
    • Paymentwall
    • Robokassa
    • CoinPayments
  3. Third-party Bridges
    • myCRED for Visual Composer
    • myCRED for UserPro
    • myCRED for Users Ultra
  4. Games
    • Lottery Add-on
    • Scratch Cards Add-on
  5. Enhancements
    • Notifications Plus
    • Transfer Plus
    • Twilio Transfers
    • Video Add-on
    • BuddyPress Charges
    • Partial Payments – WooCommerce
  6. Store Gateways
    • Jigoshop
    • Easy Digital Downloads
    • WPMUDEV Fundraising
  7. Freebies
    • BP Group Leaderboards
    • myCRED for Events Manager Pro
Chapter V
For Developers
  1. Introduction
  2. White Labeling
  3. Flowcharts
  4. Playing with Balances
  5. myCRED Objects
  6. Log API
  7. Hook API
  8. Module API
  9. Gateway API
  10. Remote API
    • Version 1.0
    • Version 2.0
  11. Front-end Encryption
Chapter VI
Reference Guides
  1. Log References
  2. Shortcodes
  3. Template Tags
  4. Globals
  5. Constants
  6. Actions
  7. Filters
  8. Objects
  9. Functions
  10. Classes
Point Balances

Each user on your website has their own balance. This balance is stored as a custom user meta, just like any other user detail in WordPress. This also means that if you backup your wp_usermeta table in your database, you are also backing up your users balances.

myCRED manipulates these user meta via a set of functions to provide support for some of it’s core features. Depending on your setup, and what myCRED features you require, you can use either functions myCRED provides or functions WordPress provides.

Point Type Identification

Since version 1.4, myCRED has built-in support for managing multiple point types. This means that a user will potentially have multiple balances, one for each point type they are not excluded from. To keep track of this, myCRED stores balances under their “point type key” which is used as the meta_key.

Point type keys are sanitized using sanitize_key, which means they must be alphanumeric and lowercase.

Current vs. Total Balance

Each user has two balances for each point type a website uses. This is to accommodate certain myCRED features, for example the Ranks add-on.

A users current balance is the amount of points that the user has right now. Their total balance is the total number of points a user has gained based of their history. In most cases the two balances will be the same with the exception of manual adjustments of a users balance by an administrator.

This is used by the Ranks add-on to allow a user to keep their rank even if they spend their points causing their current balance to diminish (e.g. spend points in your store). In this example, if ranks are based of a users current balance, then they would be demoted when using their points.

The Default Point Type

myCRED will store the default point type on a website under the meta_key mycred_default. As of version 1.7, you can change this using the MYCRED_DEFAULT_KEY constant.

Custom Point Types

When you create a new point type, you are required to set a unique point type key. This key is then used to identify balances for this point type. This of course also means that if a third-party system also stores points as a custom user meta, you could manage that point type in myCRED by creating a new point type using the same key as the third-party system.

Exclude Users

myCRED allows you to exclude users and/or administrators from having a balance. Being excluded also means that you can not use any myCRED feature since you lack a balance. You can exclude users in two ways:

Exclude by ID

You can add their ID to the exclusion list in your point type settings. This list uses a comma separated list of IDs.

Exclude Admins

You can also select to automatically exclude “Point Editors” or “Point Administrators”.

Alternatively you can also use the mycred_exclude_user filter and adjust users you want excluded from a particular point type via script.

myCRED Core Settings for your point type.
Excluded users do not have a balance.
Multisites

On multisite installations a users meta data is stores in one table which means if a user needs to have a unique balance on each site, we can not use the point type key setup. This would mean a user would have the same balance on all sites (if they are member on more then one).

To get around this, myCRED appends the sites Blog ID to the meta key. This way a user can have a unique balance on each site. You can disable this using the “Central Logging” feature in myCRED. When central logging in enabled, a user will have the same balance and history on all sites.

Figure 1. Point type key comparisons based on WordPress usage.

Regular WordPress WordPress Multisites
Point Type Balance / Total With Central Logging Without Central Logging
Default Point Type
Current Balance
mycred_default mycred_default mycred_default_{blog_id}
Default Point Type
Total Balance
mycred_default_total mycred_default_total mycred_default_{blog_id}_total
Custom Point Type
Current Balance
mypointtype mypointtype mypointtype_{blog_id}
Custom Point Type
Total Balance
mypointtype_total mypointtype_total mypointtype_{blog_id}_total

Last edited February 15, 2017

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
  • Hire a Developer
  • Support Forums
  • Plugin Changelog
  • Contact

Copyright 2013 - 2018 Gabriel S Merovingi; All rights reserved. myCRED is licensed under GPL 2.0

Terms & Conditions • Use of Cookies • Store Policy • Community RulesHosted by One.com

myCRED Donations

Donate via PayPal

Donate via PayPal

Donate Bitcoin

myCRED Bitcoin Wallet

3LVrDPjgTkPfqGARXwAZW9cJBQEYo4FHsB

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.