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. ProgressBar
    • mycred_badges_progress
    • mycred_my_ranks_progress
  2. The myCRED Store
  3. buyCRED Gateways
    • Stripe
    • Payza
    • Wepay
    • PayFast
    • 2checkout
    • Coinbase
    • ComproPago
    • Paymentwall
    • Robokassa
    • CoinPayments
  4. Third-party Bridges
    • myCRED for WPBakery Page Builder
    • myCRED for UserPro
    • myCRED for Users Ultra
  5. Games
    • myCred Learndash
    • Fortune Wheel Addon
    • Lottery Add-on
    • Scratch Cards Add-on
    • Custom Set for Scratch Card Add-on
  6. Enhancements
    • Notifications Plus
    • Transfer Plus
    • Twilio Transfers
    • Video Add-on
    • Video Add-on for JW Player
    • BuddyPress Charges
    • Partial Payments – WooCommerce
  7. Store Gateways
    • Jigoshop
    • Easy Digital Downloads
    • WPMUDEV Fundraising
  8. 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

mycred_add

Package: mycred/balance Category: Filters
Description

This filter is one of the most central filters in myCRED. Each time a user is to gain or loose points, the request is passed through this filter to allow external parties or custom code snippets from stopping a transaction.

When using this filter, keep in mind other scripts that also use this filter. Code snippets using this filter before your code snippet fires might have already declined the transaction which you will need to honour.

Available since version 1.0

Parameters
Param Type Required Description
$reply bool Yes

The result of this filter. Should either be true (run the request) or false (stop the request).

$request array No

The request array with information that will be passed on to the processor if the request is approved. The array structure is the same as the log structure.

$mycred obj No

The current myCRED_Settings class object.

You should not change a users balance or add log entries in this filter or you will create an infinite loop.

Used By
Package Prio. Description
mycred/banking 1 The central banking service uses this filter to stop transactions if the central bank runs out of points.
Examples

Example 1: Stop user 1 from gaining points for approved comments.

Example 2: Prevent your users balance from going minus.

Back To Top

mycred_add_finished

Package: mycred/balance Category: Filters
Description

This filter is the last filter that runs once a transaction has been processed, no matter of the outcome. You can use this filter to detect point gains / loses in order to do some custom tasks based on the request.

Available since version 1.6

Parameters
Param Type Required Description
$result bool Yes

The transaction result. Returns either TRUE if the transaction was executed or FALSE if the transaction was declined.

$request array No

The transaction request that was processed as returned by the mycred_run_this shortcode.

$mycred obj No

The myCRED_Settings class object processing the transaction request.

Used By
Package Prio. Description
mycred/rank 20 Used to determine if the transaction promotes or demotes a users rank.
mycred/badge 30 Used to determine if a successful transaction should earn the user a badge.
mycred/notice 40 Used to determine if the transaction should trigger a popup notification.
mycred/email 50 Used to determine if the transaction should trigger an email notification.
Example

Example 1: Send an email when a user buys points using the buyCRED add-on.

Back To Top

mycred_affiliate_cookie

Package: mycred/core Category: Filters
Description

This filter allows you to change the lifespan of the cookies your users receive from the “Points for referrals” hook. By default the cookies lifespan is set to 24 hours.

Available since version 1.4.1

Parameters
Param Type Required Description
$lifespan int Yes

A unix timestamp when the cookie will expire. By default this is 24 hours from the current time.

$signup bool No

Indicates if this is for the signup (true) or the visitor (false) cookie.

$hook obj No

The Points for Referrals hook class object.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Change the cookies lifespan from 24 hours to 1 year.

Back To Top

mycred_affiliate_key

Package: mycred/core Category: Filters
Description

This filter allows you to adjust the affiliate referral key that the hook uses. By default this is mref.

Available since version 1.3

Parameters
Param Type Required Description
$key string Yes

The key. Defaults to mref.

$hook obj No

The hook object.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Change the affiliate key in myCRED to “affiliate_id“ instead of “mref“.

Example 2: Change the affiliate key only for a custom point type. Keep the default one for the default point type.

Back To Top

mycred_all_references

Package: mycred/log Category: Filters
Description

This filter allows you to add / remove / rename any of the built-in myCRED references.

Available since version 1.5

Parameters
Param Type Required Description
$list array Yes

An associative array of references that have been registered in myCRED.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Add a custom reference.

Back To Top

mycred_allowed_tags

Package: mycred/log Category: Filters
Description

This filter allows you to change the HTML elements that myCRED will allow in the history shortcode.

This filter is part of a depreciated feature in myCRED. As of version 1.7, myCRED uses wp_kses_post to sanitize fields and with that allow the usage of HTML elements that you in post content fields.

Available since version 1.1

Parameters
Param Type Required Description
$allowed array Yes

Array of HTML elements and their attributes that are allowed to be used.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Change the allowed HTML elements to only accept paragraphs and Emphasized text.

Back To Top

mycred_apply_exchange_rate

Package: mycred/core Category: Filters
Description

This filter allows you to change the results of the apply_exchange() class method in the myCRED_Settings object. This class method is used by the MarketPress and WooCommerce payment gateways to calculate the cost of an order in points.

Available since version 1.4

Parameters
Param Type Required Description
$exchange int or float Yes

The final exchange value.

$amount int or float No

The amount to be exchanged. Usually a real life currency.

$rate int or float No

The exchange rate being applied to $amount in order to get the $exchange.

$round bool No

Indicates if the amount should be rounded (TRUE) or not (FALSE).

Used By
Package Prio. Description
mycred/payment 10 MarketPress payment gateway.
mycred/payment 20 WooCommerce payment gateway.

Back To Top

mycred_badge_image

Package: mycred/badge Category: Filters
Description

This filter allows you to adjust the badge image element before it is rendered.

Available since version 1.7.6

Parameters
Param Type Required Description
$html string Yes

The badge image element.

$image int or string No

Either main when the main badge image is requested or the image level. Note that image levels start from zero and not one. So if your badge only has one level, that first level will have the ID zero.

$badge_object obj No

The myCRED_Badge object.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Add a Bootstrap tooltip to all badge images except for the main badge image.

Back To Top

mycred_badge_user_value

Package: mycred/badge Category: Filters
Description

This filter allows you to adjust the value that badges add-on saves when a user earns a new badge / badge level. By default, the add-on saves the badges level ID but if you do not use levels you can use this to store other types of data as long as it is a string or integer value.

Available since version 1.2

Parameters
Param Type Required Description
$new_level int Yes

The new level ID a user earned. Remember that Level IDs start from ZERO and not from 1.

$user_id int No

The users WordPress id.

$badge_id int No

The badges post object ID.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_banking_save_interest

Package: mycred/banking Category: Filters
Description

This filter allows you to add or adjust the settings saved by the compound interest banking service.

Available since version 1.4

Parameters
Param Type Required Description
$settings array Yes

An associative array of settings for the service.

$service obj No

The Compound Interest class object.

$rescheduled bool No

Returns true if the service was re-scheduled or false if not.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_banking_save_recurring

Package: mycred/banking Category: Filters
Description

This filter allows you to save custom settings you might have added to the Recurring Payout service in the Banking add-on.

Available since version 1.4

Parameters
Param Type Required Description
$settings array Yes

An associative array of settings for the service.

$service obj No

The Recurring Payout class object.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_bp_leaderboard_{$column_id}_column

Package: mycred/buddypress Category: Filters
Description

This filter allows you to render the contents of a custom leaderboard column in the myCRED BP Group Leaderboards plugin.

Available since version 1.1

Parameters
Param Type Required Description
$content string Yes

The column content as a string.

$row obj No

The leaderboard row object.

$group_id int No

The current BuddyPress Group ID.

$point_type string No

The myCRED point type key the leaderboard is based on.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Render the content of a custom leaderboard column we created with the ID “avatar“.

Back To Top

mycred_bp_leaderboard_columns

Package: mycred/buddypress Category: Filters
Description

This filter allows you to adjust the leaderboard table columns that the myCRED BP Group Leaderboards plugin creates.

Available since version 1.0

Parameters
Param Type Required Description
$columns array Yes

An associative array of column IDs and their labels.

Default columns:

Column ID Description
position The users leaderboard position.
member The group member.
balance The point value.
Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Rename the position column to “Rank“ in BP Group Leaderboards.

Example 2: Re-order the leaderboard columns.

Example 3: Add a custom column called “Avatar“ for leaderboards.

Back To Top

mycred_bp_leaderboard_find_position

Package: mycred/buddypress Category: Filters
Description

This filter allows you to adjust or query a users leaderboard position. The myCRED BP Group Leaderboard plugin will cache the users position automatically, which means that this filter only fires when the cache has been deleted and a new query is needed. This means you do not need to check if a cached version exists when this filter runs.

Available since version 1.0

Parameters
Param Type Required Description
$position int Yes

The users numeric position in the leaderboard.

$group_id int No

The BuddyPress Group ID.

$user_id int No

The numeric WordPress user ID.

$point_type string No

The point type key the leaderboard is based on.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Example showing how we can query a users position in an annual leaderboard.

Back To Top

mycred_bp_leaderboard_get

Package: mycred/buddypress Category: Filters
Description

This filter allows you to adjust or run your own custom query for BuddyPress leaderboards. This filter used by the myCRED BP Group Leaderboards plugin. The filter is used each time a leaderboard is rendered so it is important that you cache your results to prevent having to run potentially expensive queries on every page load.

Available since version 1.1

Parameters
Param Type Required Description
$leaderboard array Yes

The leaderboard array.

$group_id int No

The BuddyPress Group id.

$point_type string No

The myCRED point type the leaderboard is based on.

$append_user int or bool No

The WordPress user ID of a user to append to the end of the leaderboard. FALSE if no appending should occur. Note that users that are excluded from the point type will never be appended to  leaderboard so there is no need in your script to check if the user ID is excluded or not.

$fresh bool No

TRUE if a new fresh query should be made (ignoring cached results) or FALSE if cached results should be used (if one exists).

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Example of how to run a custom leaderboard query based on annual point gains.

Back To Top

mycred_bp_leaderboard_types

Package: mycred/buddypress Category: Filters
Description

This filter allows you to adjust, add or remove leaderboards types in the myCRED BP Group Leaderboards plugin.

Available since version 1.1

Parameters
Param Type Required Description
$leaderboards array Yes

An associative array of leaderboard type keys and labels.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Example on how to remove one type and adding another.

function mycred_pro_adjust_bp_leaderboard_types( $leaderboards ) {

	// Remove total balance lederboards
	unset( $leaderboards['total'] );

	// Add a custom leaderboard
	$leaderboards['year'] = 'Annual Leaderboard';

	return $leaderboards;

}
add_filter( 'mycred_bp_leaderboard_types', 'mycred_pro_adjust_bp_leaderboard_types' );

Back To Top

mycred_bp_rank_in_header

Package: mycred/rank Category: Filters
Description

This filter allows you to adjust the way ranks are rendered in the BuddyPress user profile header (if used).

Available since version 1.4

Parameters
Param Type Required Description
$content string Yes

The rendered HTML elements.

$user_id int No

The user ID of the profile where the ranks are being rendered.

$buddypress obj No

The BuddyPress module class object.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Only show the users rank title without any extra HTML elements in their profile header.

Back To Top

mycred_bp_rank_in_profile

Package: mycred/rank Category: Filters
Description

This filter allows you to adjust the way ranks are rendered in the BuddyPress user profile (if used).

Available since version 1.4

Parameters
Param Type Required Description
$content string Yes

The rendered HTML elements.

$user_id int No

The user ID of the profile where the ranks are being rendered.

$buddypress obj No

The BuddyPress module class object.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Only show the users rank title without any extra HTML elements in their profile header.

Back To Top

mycred_buycred_get_cost

Package: mycred/purchase Category: Filters
Description

This filter allows you to adjust the cost of buying points using the buyCRED add-on. This filter is used both when calculating the cost when the request is made and when the payment gateway verifies the amount the user actually paid.

Available since version 1.4

Parameters
Param Type Required Description
$cost int or float Yes

The cost of the purchase.

$amount int or float No

The amount of points being purchased.

$type string No

The point type key being purchased.

$gateway_prefs array No

The selected payment gateways settings.

$buycred_prefs array No

The buyCRED add-ons settings.

Remember that most payment gateways require the cost to be formatted using two decimal places.

Used By
Package Prio. Description
mycred/purchase 10 Used by the selected payment gateway to calculate the cost.
Examples

Example 1: Adjust the price of buying points based on the amount of points a user selects to buy.

Example 2: Apply a 10% discount on point purchases no matter how many points a user buys.

Example 3: Apply a 10% discount on purchases of a custom point type, no matter how many points the user selects to buy.

Back To Top

mycred_central_banking_ignore

Package: mycred/banking Category: Filters
Description

Used by the central banking service in the Banking add-on, this filter allows you to inform the add-on which references it should ignore. By default, transfers and interest payouts are ignored by the central bank, preventing large number of log entries to be saved with each event.

Available since version 1.5.2

Parameters
Param Type Required Description
$references array Yes

An Array of references that should be ignored by the central bank. Defaults to: interest, recurring_payout and transfer.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Add the custom reference “gift“ to the list.

function mycred_pro_add_bank_exception( $references ) {

	$references[] = 'gift';
	return $references;

}
add_filter( 'mycred_central_banking_ignore', 'mycred_pro_add_bank_exception' );

Back To Top

mycred_compound_max_limit

Package: mycred/banking Category: Filters
Description

This filter allows you to adjust the number of balances the compound interest banking service will process per instance. By default this is 1500. If more then 1500 balances need to be compounded, the compound interest schedule will re-schedule itself and run another 1500 users 2 min later until all balances are processed.

The value you set should be the number of users that your website can process based on your servers max execution limit. On most servers this is 30 seconds which the default 1500 value is based on.

Available since version 1.7

Parameters
Param Type Required Description
$limit int Yes

The number of balances to compound per instance.

$service obj No

The compound interest banking service object.

Used By
Package Prio. Description
mycred/banking 10 Default usage

Back To Top

mycred_compound_pay_max_limit

Package: mycred/banking Category: Filters
Description

This filter allows you to adjust the number of compounded interests the banking service will payout per instance. By default this is 1500. If more then 1500 compounded interests that need to be compounded, the compound interest schedule will re-schedule itself and run another 1500 users 2 min later until everyone has been paid.

The value you set should be the number of users that your website can process based on your servers max execution limit. On most servers this is 30 seconds which the default 1500 value is based on.

Available since version 1.7

Parameters
Param Type Required Description
$limit int Yes

The number of compounded interests to payout per instance.

$service obj No

The compound interest banking service object.

Used By
Package Prio. Description
mycred/banking 10 Default usage

Back To Top

mycred_decline_store_purchase

Package: mycred/payment Category: Filters
Description

This filter allows you to decline a store purchase where points are used as payment. This filter is usable for all supported shopping cart plugins.

Available since version 1.5

Parameters
Param Type Required Description
$result bool or string Yes

Should return false if the transaction should complete or a string message if the transaction should be declined. This string message is then shown to the user as the reason why the transaction was declined.

$cart array or obj No

This is either the cart object or the order object, depending on the shopping cart plugin used.

$gateway obj No

The gateway object.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Decline point payment in WooCommerce if a user does not have at least 100 point left after payment.

Back To Top

mycred_delete_hook_ref

Package: mycred/hook Category: Filters
Description

This filter allows you to adjust the reference that the Points for Deleting Content hook uses when awarding / deducting points. Defaults to deleted_content.

Available since version 1.8

Parameters
Param Type Required Description
$reference string Yes

The reference to use. Can not be empty or no points will be awarded!

$post obj No

The WordPress post object that is getting deleted.

$hook obj No

The hook object.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_em_approve_on_pay

Package: mycred/payment Category: Filters
Description

When using Events Manager, you can select if bookings should be approved on payment or if admin approval is required. In case you select admin approval, you can use this filter to override this and approve the booking when paid using points.

Available since version 1.5

Parameters
Param Type Required Description
$override bool Yes

Should return TRUE if the event should be approved or FALSE if not.

$booking obj No

The event booking object.

$gateway obj No

The myCRED Gateway object class.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_email_before_send

Package: mycred/email Category: Filters
Description

This filter allows you to adjust the details of an email notification before it is sent.

Available since version 1.5

Parameters
Param Type Required Description
$email array Yes

An associative array of email details:

  • to – The email recipient
  • subject – The email subject
  • message – The email body
  • headers – The email headers
  • attachments – Email attachments
  • request – The myCRED Request that triggered this email
  • email_id – The email notice id

Used By
Package Prio. Description
mycred/payment 10 The WooCommerce gateway uses this filter to render the order details before the email is sent.
mycred/payment 20 The MarketPress gateway uses this filter to render the order details before the email is sent.
mycred/payment 30 The WP E-Commerce gateway uses this filter to render the order details beforethe email is sent.
mycred/content 40 The Sell Content add-on uses this filter to render the purchase details before the email is set.
mycred/transfer 50 The Transfer add-on uses this filter to render the transfer before the email is sent.
Example

Example 1: Append a footer to all emails sent by the Email Notifications add-on.

Back To Top

mycred_email_instances

Package: mycred/email Category: Filters
Description

This filter allows you to add / remove or adjust email instances that is selectable when creating or editing an email notice.

Available since version 1.1

Parameters
Param Type Required Description
$instances array Yes

An associative array of grouped email instances.

Instances

Email instances are presented in groups. For example gaining or loosing points are both part of the “General” instance. myCRED groups instances by add-on, so there is one group for “Transfers” which contains two instances: receiving points and sending points.

When you add your own instance, you must select between adding your own group (even if you only want to add one instance) or add your unique instance into an existing group.

Instance Example

This is the "General" group which contains 5 unique instances.

Array
(
    [general] => Array
        (
            [label] => General
            [all] => users balance changes
            [positive] => user gains %_plural%
            [negative] => user lose %_plural%
            [zero] => users balance reaches zero
            [minus] => users balance goes minus
            [end] => 
        )

)

When adding your own group, the settings array must contain at minimum 3 items:

  • label – The label shown in the dropdown menu when editing an email notice. This must always be the first item in the array.
  • yourinstance – A unique ID identifying your custom instance.  This ID is then used by you when you need to identify an instance that should trigger these type of emails.
  • end – Always the last item in the array, this item indicates the end of the group. Left for backwards compatibility.

You might have noticed from the above example that the instance labels are always lowercase. This is because your label will be appended after the sentence: “Send email notice when …”. For example: “Send email notice when … users balance changes”.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Add a custom email instance for when a users balance reaches 1000 points. Insert the instance under the “General“ group.

Back To Top

mycred_exclude_user

Package: mycred/core Category: Filters
Description

This filter allows you to exclude users from using myCRED via script. This filter is part of the exclude_user() method in the myCRED_Settings class and is used extensively in myCRED. Returning true will stop the user in question from gaining points or using myCRED features.

Available since version 1.0

Parameters
Param Type Required Description
$exclude bool Yes

Should return TRUE if user is to be excluded or FALSE if not.

$user_id int No

The ID of the user in question.

$mycred obj No

The myCRED_Settings class object being used.

Used By
Package Prio. Description
Not used by any built-in package.
Examples

Example 1: Exclude users with the subscriber role in WordPress from using myCRED.

Example 2: Example 2: Exclude users with the Paid Membership Pro level of “Gold“ from using myCRED.

Example 3: Exclude subscribers from a custom point type.

Example 4: Exclude users from using points based on their BuddyPress Member Type (2.7+)

Back To Top

mycred_export_headers

Package: mycred/core Category: Filters
Description

This filter allows you to adjust what columns should be included when myCRED log entries are exported. You can use this in combination with the mycred_log_$column filter to render each columns content.

Available since version 1.7

Parameters
Param Type Required Description
$headers array Yes

An associative array of column ids and their corresponding labels.

$raw bool No

Indicates if the export is selected to be done “raw” TRUE or “formatted” FALSE.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_find_users_rank

Package: mycred/rank Category: Filters
Description

Used by the mycred_find_users_rank function, the results of that search is passed through this filter. This allows you to execute custom code when myCRED needs to look if a user gains a new rank.

Available since version 1.5

Parameters
Param Type Required Description
$results obj or bool Yes

The results object or FALSE if no rank was found.

$user_id int No

The ID of the user for whom we requested to find a rank.

$point_type string No

The point type for which the rank is queried. Added in 1.6.

Results Object

Property Type Description
Results Object (
rank_id int The rank ID a user should have.
current_id int The rank ID a user currently have.
minimum int or float The minimum point requirement for the rank the user should have.
maximum int or float The maximum point requirement for the rank the user should have.
ctype string The point type associated with the rank.
)
Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Reward users with 10 bonus points each time they gain a new rank. Note that this example assumes users only gain rank and do not get demoted. If they do, they will gain points for that as well.

Back To Top

mycred_format_creds

Package: mycred/balance Category: Filters
Description

This filter allows you to make adjustments to points before they are rendered on your website. If your point type is setup to use a prefix or suffix, these will be attached to the balance when passed through this filter.

Besides the myCRED_Settings class, this filter is also triggered by the AffiliateWP Hook.

Available since version 1.0

Parameters
Param Type Required Description
$points string Yes

The point amount rendered with prefix / suffix (if used).

$amount int or float No

The original amount before it was formatted.

$mycred obj No

The myCRED_Settings class object.

Used By
Package Prio. Description
Not used by any built-in package.
Examples

Example 1: Since prefixes and suffixes can not contain HTML in your settings, lets add a FontAwesome icon as a prefix to points before they are rendered.

Example 2: Adjust the layout of how our custom point type is presented. In this example, we present it as US Dollars with two decimals. Default point type is rendered as is.

Back To Top

mycred_format_number

Package: mycred/balance Category: Filters
Description

This filter is used to format a points value before it is displayed. You can use this filter to adjust how points are displayed before the value gets a prefix or suffix appended to it (if used). Not used in point calculations.

Available since version 1.0

Parameters
Param Type Required Description
$formatted int or float Yes

The point value formatted based on the point type setup.

$number int or float No

The original value.

$mycred obj No

The myCRED_Settings class object.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Even though we use decimals, when displaying points, we always display them as integers.

Back To Top

mycred_get_content_price

Package: mycred/content Category: Filters
Description

This filter allows you to adjust the price of a content that has been set for sale using the Sell Content add-on. If you are looking to customize who needs to pay for the content, consider using the mycred_user_has_paid_for_content filter instead.

Available since version 1.7

Parameters
Param Type Required Description
$price int or float Yes

The price in points.

$post_id int No

The post object ID.

$point_type string No

The point type that the price is requested for.

$user_id int No

The numeric ID of the user who needs to pay for this content.

Used By
Package Prio. Description
mycred/content 10 Used by the Sell Content add-on.
Example

Example 1: Set a custom price for post authors as they view other authors content, with an override option using custom post meta.

Example 2: Example of how the filter can be used to set custom prices based on post type or taxonomy relationships.

Back To Top

mycred_get_users_cred

Package: mycred/balance Category: Filters
Description

Each time a users balance is requested by a feature, the balance is passed through this filter. This could for example be used as a mean to retrieve balances from a different source then the user meta table.

Available since version 1.2

Parameters
Param Type Required Description
$balance int or float Yes

The balance value.

$mycred obj No

The myCRED_Settings class object.

$user_id int No

The requested users ID.

$type string No

The point type being requested.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Load balances that exist in a separate database table and not in the user meta table.

Back To Top

mycred_give_run

Package: mycred/core Category: Filters
Description

This filter controls if the mycred_give shortcode should run or not. It can be used to either disable this shortcode or to limit when or by whom it can be used.

Available since version 1.8

Parameters
Param Type Required Description
$run bool Yes

If the shortcode is set to run (TRUE) or not (FALSE).

$atts array No

The shortcode attributes that are being used.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Disable usage of this shortcode.

add_filter( 'mycred_give_run', '__return_false' );

Back To Top

mycred_has_entry

Package: mycred/log Category: Filters
Description

Used by the has_entry() class method when checking if a particular log entry exists for a given user. Mainly used to make sure log entries are unique.

Available since version 1.3

Parameters
Param Type Required Description
$result bool Yes

Returns TRUE if the log entry exists or FALSE.

$reference string No

The reference being checked. Is NULL if not used.

$ref_id int No

The reference ID being checked. Is NULL if not used.

$user_id int No

The user ID being checked. Is NULL if not used.

$data string No

The log data being checked. If used, this can be a string or a serialized array. Is NULL if not used.

$type string No

The point type being checked.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_have_ranks

Package: mycred/rank Category: Filters
Description

Used by the mycred_have_ranks function when checking if any ranks exists for a given point type.

Available since version 1.3

Parameters
Param Type Required Description
$results bool Yes

Returns TRUE if ranks exists or FALSE.

$point_type string No

The point type being checked. Is NULL if checking no matter which point type is installed.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_label

Package: mycred/core Category: Filters
Description

This filter allows you to change the value of the MYCRED_DEFAULT_LABEL constant, re-naming  the myCRED plugin. While it is recommended to use the constant to change the label, this filter is a better solution when the constant can not be used, e.g. when re-naming the plugin via another plugin.

Available since version 1.1

Parameters
Param Type Required Description
$label string Yes

The MYCRED_DEFAULT_LABEL value.

Example

Example 1: Change the myCRED plugin name to SuperPoints.

Back To Top

mycred_label_my_balance

Package: mycred/balance Category: Filters
Description

This filter allows you to change how a users balance is displayed in the toolbar (if used). The default layout used is: %plural%: %cred_f%. You can use any general template tags or amount related template tags.

Available since version 1.3.1

Parameters
Param Type Required Description
$template string Yes

The template string.

$user_id int No

The ID of the users balance we are showing.

$point_type string No

The point type used.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Change the template to show the word “Your Balance“ followed by the users balance.

Back To Top

mycred_link

Package: mycred/core Category: Filters
Description

This filter allows you to adjust the anchor element the mycred_link shortcode renders.

Available since version 1.7.6

Parameters
Param Type Required Description
$html string Yes

The HTML anchor element.

$atts array No

The shortcode attributes being used.

$link_title string No

The link title set for the shortcode.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_log_{column}

Package: mycred/log Category: Filters
Description

This filter allows you to return the content of a custom column that you have added using the mycred_log_column_headers filter. This filter is used by both the myCRED_Query_Log class when showing log entries and the myCRED_Export class when exporting. The filter name consists of mycred_log_ followed by the column ID you set.

You can not use this filter to replace the content of the built-in columns in myCRED! There are dedicated filters for each column that needs to be used instead.

Available since version 1.0

Parameters
Param Type Required Description
$content string Yes

The default column content. If the filter is used by the myCRED_Query_Log class, this will be FALSE while if it is used myCRED_Export class it will be an empty string.

$entry obj No

The database row object for the entry in question.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Render the content of a custom column with the id “row-id“.

Back To Top

mycred_log_bulk_actions

Package: mycred/log Category: Filters
Description

This filter allows you to adjust the bulk actions that are available on the log page in the admin area.

Available since version 1.7

Parameters
Param Type Required Description
$actions array Yes

An array of bulk actions ids and action labels.

$module obj No

The myCRED_Log_Module class object.

Default Bulk Actions

Action ID Label
-1 Bulk Actions
export-raw Export Raw
export-format Export Formatted
delete Delete
Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Remove bulk actions in the logs.

Back To Top

mycred_log_column_{type}_headers

Package: mycred/log Category: Filters
Description

This filter allows you to adjust or add columns that are shown when viewing the log in the admin area for a specific point type.

Available since version 1.7

Parameters
Param Type Required Description
$columns array Yes

An array of column IDs and column labels.

$class obj No

Either the log module class object if in the admin area or the myCRED_Query_Log class object if used in the front end.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Remove the date column from the default point type only.

Back To Top

mycred_log_column_headers

Package: mycred/log Category: Filters
Description

This filter allows you to adjust or add columns that are shown when viewing the log history table. This filter is used both in the front end when viewing your history or on the log pages in the admin area.

If you want to change / add columns only when viewing a specific point type in the admin area, use the mycred_log_column_{type}_headers filter instead.

Available since version 1.0

Parameters
Param Type Required Description
$columns array Yes

An array of column IDs and column labels.

$class obj No

Either the log module class object if in the admin area or the myCRED_Query_Log class object if used in the front end.

$is_admin bool No

Returns TRUE if the filter is used in the front end when for example using the mycred_history shortcode or FALSE if used in the admin area.

Used By
Package Prio. Description
mycred/buddypress 10 The BuddyPress module uses this filter to remove the User column when showing the log entry in a users profile.
Examples

Example 1: Add a custom column called “Entry ID“ that are shown both in the front end and in the admin area.

Example 2: Remove the date column when viewing the log in the front end.

Back To Top

mycred_log_date

Package: mycred/log Category: Filters
Description

This filter allows you to adjust how dates in the log or in exports are presented.

Available since version 1.2

Parameters
Param Type Required Description
$date string Yes

The formatted date to show.

$time int No

The original unix timestamp being formatted.

$entry obj No

The log entry object.

Used By
Package Prio. Description
mycred/log 10 Used by the log query class.
mycred/log 20 Used by the export module.
Example

Example 1: Instead of showing a date for each log entry, we show time ago.

Back To Top

mycred_log_row_classes

Package: mycred/log Category: Filters
Description

This filter allows you to adjust, add or remove CSS classes for each table row when viewing the log.

Available since version 1.4

Parameters
Param Type Required Description
$classes array Yes

Array of CSS classes.

$entry obj No

The log entry object.

Used By
Package Prio. Description
mycred/log 10 Used by the log query class.
Example

Example 1: Add custom CSS classes indicating if the entry value is positive or negative.

Back To Top

mycred_lotto_payout_type

Package: mycred/game Category: Filters

Filter Description

This filter allows you to change what point type you want users to be paid out in when playing a lottery. Requires you to have more then one point type setup.

Available since

myCRED Lottery add-on 1.2.2.

Navigation

  • Description
  • Used by
  • Parameters
  • Examples

Used by

  • Function: mycred_lottery_do_draw

Parameters

  • ctype (string)
    The point type metakey to use.
  • lottery (object)
    The lottery object.

Examples

Example 1: Basic usage example where we set users to be paid in the custom point type “mytype”.

add_filter( 'mycred_lotto_payout_type', 'adjust_mycred_lottery_payouttype' );
function adjust_mycred_lottery_payouttype( $type ) {
	return 'mytype';
}

Back To Top

mycred_lotto_times12

Package: mycred/game Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This filter allows you to adjust the available times a lottery can be scheduled using the 12 hour system. This filter is used by the drop-down menus for the lottery schedules.

See the mycred_lotto_times24 filter for 24 hour systems.

 

Used By

  • Function: mycred_lotto_time_dropdown

 

Parameters

  • times (array)
    An assosiative array of times and textual labels to show in the dropdown menu.

Back To Top

mycred_lotto_times24

Package: mycred/game Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This filter allows you to adjust the available times a lottery can be scheduled using the 24 hour system. This filter is used by the drop-down menus for the lottery schedules.

See the mycred_lotto_times12 filter for 12 hour systems.

 

Used By

  • Function: mycred_lotto_time_dropdown

 

Parameters

  • times (array)
    An assosiative array of times and textual labels to show in the dropdown menu.

Back To Top

mycred_notice_js

Package: mycred/notice Category: Filters
Description

This filter allows you to adjust the JavaScript variables for the Notifications Plus script. You can use this to make adjustments to the notifications before they are rendered or adjust the add-on settings.

Available since version 1.3.6

Parameters
Param Type Required Description
$args array Yes

Associative array of arguments.

$module obj No

The myCRED Notifications Plus module object.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Disable front end debugging for administrators.

Back To Top

mycred_notifications

Package: mycred/notice Category: Filters
Description

This filter is used to pass on notifications from the saved transient to the jQuery script. It can be used to filter existing notifications or adding / removing a particular notice.

Available since version 1.3

Parameters
Param Type Required Description
$notifications array No

Array of notifications.

Used By
Package Prio. Description
mycred/notice 10 Used by the notification add-on to get notifications.

Back To Top

mycred_notifications_note

Package: mycred/notice Category: Filters
Description

This filter allows you to adjust the popup notification template before it is saved. This is then rendered and shown to the user on the next page load.

Available since version 1.3

Parameters
Param Type Required Description
$template string Yes

The notification template.

$request array No

The point request array that triggered this notification.

$mycred obj No

The myCRED point type object.

Used By
Package Prio. Description
mycred/notice 10 Used by the notification add-on.

Back To Top

mycred_parse_tags_amount

Package: mycred/log Category: Filters
Description

This filter allows you to adjust or add your own custom amount related template tag, to use in log entries. Should be used in combination with the mycred_has_tags filter in order to work.

Available since version 1.0

Parameters
Param Type Required Description
$content string Yes

The rendered log entry string.

$amount int or float No

The original point amount.

$mycred obj No

The myCRED point type object.

Used By
Package Prio. Description
mycred/core 10 Used by the myCRED_Settings class.
Example

Example 1: Add a custom template tag that renders the points amount with a dollar sign.

Back To Top

mycred_parse_tags_comment

Package: mycred/log Category: Filters
Description

This filter allows you to adjust or add your own custom comment related template tag to use in log entries. Should be used in combination with the mycred_has_tags filter in order to work.

Available since version 1.0

Parameters
Param Type Required Description
$content string Yes

The rendered log entry string.

$comment obj No

The WordPress comment object.

$data array No

The value stored in the data column of the log entry.

Used By
Package Prio. Description
mycred/core 10 Used by the myCRED_Settings class.
Example

Example 1: Add a custom comment related template tag that shows the comment authors IP when the comment was posted.

Back To Top

mycred_parse_tags_general

Package: mycred/log Category: Filters
Description

This filter allows you to adjust or add your own custom generic template tag to use in log entries. It is important to remember that generic template tags are parsed on every single log entry! This means that you should only use this if you need to adjust every single log entry in your database! Furthermore, this filter is a very generic and no log entry detail besides the visible entry string is available.

Available since version 1.0

Parameters
Param Type Required Description
$content string Yes

The log entry string.

Used By
Package Prio. Description
mycred/core 10 Used by the myCRED_Settings class.

Back To Top

mycred_parse_tags_post

Package: mycred/log Category: Filters
Description

This filter allows you to adjust or add your own custom post related template tag to use in log entries. Should be used in combination with the mycred_has_tags filter in order to work.

Available since version 1.0

Parameters
Param Type Required Description
$content string Yes

The rendered log entry string.

$post obj No

The WordPress post object.

$data array No

The value stored in the data column of the log entry.

Used By
Package Prio. Description
mycred/core 10 Used by the myCRED_Settings class.
Example

Example 1: Add a custom post related template tag showing a posts status in the log entries.

Back To Top

mycred_parse_tags_user

Package: mycred/log Category: Filters
Description

This filter allows you to adjust or add your own custom user related template tag to use in log entries. Should be used in combination with the mycred_has_tags filter in order to work.

Available since version 1.0

Parameters
Param Type Required Description
$content string Yes

The rendered log entry string.

$user array or obj No

The WordPress user object or the object in array form. When a user is deleted from the database, and you have selected not to remove their log entries, myCRED will save their user object in an array form in the data column. So when rendering log entries, you need to keep this in mind accessing data.

$data array No

The value stored in the data column of the log entry.

Used By
Package Prio. Description
mycred/core 10 Used by the myCRED_Settings class.
Example

Example 1: Add a custom user related template tag showing the users avatar.

Back To Top

mycred_post_is_for_sale

Package: mycred/content Category: Filters
Description

This filter allows you to adjust the results of checking if a given post is set for sale using the Sell Content add-on. This only checks if the post is set for sale based on your settings. It does not check if a user has paid for the content!

Available since version 1.7

Parameters
Param Type Required Description
$results bool Yes

Returns TRUE if the post is for sale or FALSE.

$post obj No

The post object being checked.

$settings array No

The Sell Content add-on settings array.

Example

Example 1: Set all content for sale that are authored by the user with the ID 123.

Back To Top

mycred_pt_get_fee

Package: mycred/transfer Category: Filters
Description

When using the Transfer Plus add-on in myCRED, you can select to charge a fee for each transfer a user makes on your website. This filter allows you to adjust the fee amount for each transfer based on your preference.

Available since version 1.0

Parameters
Param Type Required Description
$fee int or float Yes

The fee amount in points. Use zero for no fee.

$amount int or float No

The amount of points a user is transferring.

$user_id int No

The numeric ID of the user that is making the transfer.

$point_type string No

The point type key of the point type we are transferring.

$prefs array No

The fee feature settings.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Charge a custom fee based on a users WordPress role when making a transfer in myCRED.

Example 2: Charge a custom fee based on a users myCRED rank when making a transfer in myCRED.

Back To Top

mycred_publish_hook_new

Package: mycred/hook Category: Filters
Description

The “Points for Publishing Content” hook reward users with points for publishing content. This act is rewarded when a posts status transitions from an “old status” to a “new status”.

The old status would include: drafts, pending for approval and scheduled post statuses. The new statuses include: published and privately published post statuses.

Any custom post statuses needs to be added in here if the status indicates content that is “published”. If your custom post status is a different type of “not published content” indicator, e.g. “Pending Approval”, the status need to be added using the mycred_publish_hook_old filter instead!

Available since version 1.6

Parameters
Param Type Required Description
$new_statuses array Yes

An array of statuses a post needs to transition to. By default these are: publish and private.

$post_id int No

The post objects ID.

$point_type string No

The point type key currently being processed.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Add a custom “Archived“ post status to the “Points for publishing content“ hook in myCRED.

Back To Top

mycred_publish_hook_old

Package: mycred/hook Category: Filters
Description

The “Points for Publishing Content” hook reward users with points for publishing content. This act is rewarded when a posts status transitions from an “old status” to a “new status”.

The old status would include: drafts, pending for approval and scheduled post statuses. The new statuses include: published and privately published post statuses.

Any custom post statuses needs to be added in here if the status is used BEFORE the content is published. If your custom post status is a different type of “published content” indicator, e.g. “Archived”, the status need to be added using the mycred_publish_hook_new filter instead!

Available since version 1.6

Parameters
Param Type Required Description
$old_statuses array Yes

An array of statuses a post needs to transition from. By default these are: new, auto-draft, draft, private, pending and future.

$post_id int No

The post objects ID.

$point_type string No

The point type key currently being processed.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Add a custom “Pre Approved“ post status to the “Points for publishing content“ hook in myCRED.

Back To Top

mycred_publish_hook_ref

Package: mycred/hook Category: Filters
Description

This filter allows you to adjust the reference that the Points for Publishing Content hook uses when awarding / deducting points. Defaults to publishing_content.

Available since version 1.8

Parameters
Param Type Required Description
$reference string Yes

The reference to use. Can not be empty or no points will be awarded!

$post obj No

The WordPress post object that is getting published.

$new_status string No

The new status the post is receiving by WordPress.

$old_status string No

The posts old status.

$hook obj No

The hook object.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Log the event under a unique reference based on the post type being published.

Back To Top

mycred_query_log_args

Package: mycred/log Category: Filters
Description

Used by the myCRED_Query_Log class, this filter allows you to make adjustments to the query arguments before it is run by class.

Available since version 1.0

Parameters
Param Type Required Description
$args array Yes

An associative array of arguments.

$defaults array No

An array of the default set of arguments the query supports.

Default Query Arguments
array
(
	'entry_id' => NULL,
	'user_id'  => NULL,
	'ctype'    => MYCRED_DEFAULT_TYPE_KEY,
	'time'     => NULL,
	'ref'      => NULL,
	'ref_id'   => NULL,
	'amount'   => NULL,
	's'        => NULL,
	'data'     => NULL,
	'number'   => 25,
	'offset'   => '',
	'orderby'  => 'time',
	'order'    => 'DESC',
	'ids'      => false,  // depreciated as of 1.7.5
	'fields'   => 'all',  // in favor for fields
	'paged'    => 1
)
Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Make sure that admins and editors can only view their own manual adjustments when viewing the log.

Back To Top

mycred_rank_list

Package: mycred/rank Category: Filters
Description

This filter allows you to adjust the template used by the mycred_list_ranks shortcode when rendering each rank you have setup for a particular point type. While you can set the template when using the shortcode, this filter accomplishes the exact same task.

Available since version 1.1.1

Parameters
Param Type Required Description
$row_template string Yes

The row template.

$atts array No

The attributes passed to the shortcode.

$mycred obj No

The myCRED object.

Used By
Package Prio. Description
mycred/rank 10 Used by the mycred_list_ranks shortcode.
Example

Example 1: Change the template used when listing ranks via the mycred_list_ranks shortcode to render details with Bootstrap support.

Back To Top

mycred_ranking_row

Package: mycred/log Category: Filters
Description

This filter allows you to adjust how each row is rendered in the leaderboard. The word “ranking” refers to a users ranking in the leaderboard and has nothing to do with the users Rank.

Available since version 1.0

Parameters
Param Type Required Description
$layout string Yes

The row string.

$template string No

The original row template.

$user obj No

The WordPress user object.

$position int No

The users position in the leaderboard.

Used By
Package Prio. Description
mycred/log 10 Used by the mycred_leaderboard shortcode.
Example

Example 1: Add avatars to each user shown in your leaderboard.

Back To Top

mycred_ranking_sql

Package: mycred/log Category: Filters
Description

This filter allows you to adjust the MySQL query string used for generating a leaderboard through the mycred_leaderboard shortcode.

Make sure you use $wpdb->prepare(); to properly escape any custom SQL code you might add using this filter.

Available since version 1.2

Parameters
Param Type Required Description
$query string Yes

The SQL query string.

$atts array No

Associative array of the shortcode attributes currently being used. Will include custom shortcode attributes that might be used.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_recurring_max_limit

Package: mycred/banking Category: Filters
Description

This filter allows you to adjust the number of users the recurring payout banking service will process per instance. By default this is 1500. If more then 1500 users needs to be paid out, the recurring payout schedule will re-schedule itself and run another 1500 users 2 min later until all users are processed.

The value you set should be the number of users that your website can process based on your servers max execution limit. On most servers this is 30 seconds which the default 1500 value is based on.

Available since version 1.7

Parameters
Param Type Required Description
$limit int Yes

The number of users to execute per instance.

$service obj No

The recurring payout banking service object.

Used By
Package Prio. Description
mycred/banking 10 Default usage

Back To Top

mycred_register_ranks

Package: mycred/rank Category: Filters
Description

This filter lets you make adjustments to the Ranks post type settings before it is handed over to the register_post_type function.

Available since version 1.1.1

Parameters
Param Type Required Description
$args array Yes

The post type settings array.

$module obj No

The myCRED_Ranks_Module class.

Used By
Package Prio. Description
mycred/rank 10 Used by the myCRED_Ranks_Module class.
Example

Example 1: Change the rank post type capability.

Back To Top

mycred_run_this

Package: mycred/balance Category: Filters
Description

This filter allows you to make adjustments to a transaction request before it is executed. If you need to stop a transaction you can set the amount to zero, however you should use the mycred_add filter to determine if a transaction should be stopped.

Available since version 1.1

Parameters
Param Type Required Description
$request array Yes

An associative array representing the transaction that is to be processed.

$mycred obj No

The myCRED_Settings class object processing the transaction request.

Used By
Package Prio. Description
mycred/core 10 Used by the myCRED_Settings class.
Example

Example 1: Multiply the amount of points users gets based on their WordPress role. Administrators are excluded.

Example 2: Whenever a user on our website is to gain points, we double the value.

Example 3: Give users bonus points when they buy points using buyCRED. The amount depends on their current rank.

Back To Top

mycred_scratch_card_templates

Package: mycred/game Category: Filters
Description

This filter allows you to add, replace or remove templates for the Scratch Card add-on.

Available since version 1.0

Parameters
Param Type Required Description
$templates array Yes

An associative array of available templates. You can read more about this in the Scratch Card documentation.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Add a custom template from a theme.

Example 2: Add a custom template from a plugin.

Back To Top

mycred_scratch_everyonewins

Package: mycred/game Category: Filters
Description

By default, a scratch card set must consist of cards that represents a “win” and cards that represents “no wins”. This filter can be used to change this and create sets where all cards are winners. Without this filter, if you attempt to create zero “No Win” cards, the set will decline your request when you save.

Available since version 1.2

Parameters
Param Type Required Description
$allow bool Yes

TRUE to allow or FALSE. Defaults to FALSE.

$set_id int No

The card sets WordPress post ID.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Enable all cards to be winning cards.

add_filter( 'mycred_scratch_everyonewins', '__return_true' );

Back To Top

mycred_sell_content_priority

Package: mycred/content Category: Filters
Description

This filter allows you to change the priority of the Sell Content add-ons content filtering.

Available since version 1.7.6

Parameters
Param Type Required Description
$priority int Yes

The priority number. Defaults to 25.

$sell_content_module obj No

The Sell Content module.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Lower the priority of the content filter.

Back To Top

mycred_sell_exp_title

Package: mycred/content Category: Filters
Description

This filter lets you change the title used to mark the expiration length measurement. Defaults to “Hours”. If you are looking to change hours to any other time measurement, consult the mycred_sell_expire_calc filter.

Available since version 1.4

Parameters
Param Type Required Description
$label string No

The title to show.

Used By
Package Prio. Description
mycred/content 10 Used by the Sell Content add-on.
Example

Example 1: Change the Expiration Label.

Back To Top

mycred_sell_expire_calc

Package: mycred/content Category: Filters
Description

By default, myCRED allows you to let purchases expire after a certain number of hours. This filter lets you change this calculation from hours to any other time measurement. If you use this filter you should also consult the mycred_sell_exp_title filter.

Remember! The returned number is added to the purchase time and compared to see if it is still in the future (purchase valid) or if that time has passed (purchase expired). For this reason the value you return must be in seconds.

Available since version 1.4

Parameters
Param Type Required Description
$expiration int No

The expiration length in seconds. This value is multiplied with the length you set e.g. 2 hours, and added to the time a user last paid.

$length int No

The length set for this particular post.

$user_id int No

The numeric ID of the user this calculation is related to.

$post_id int No

The post ID.

Used By
Package Prio. Description
mycred/content 10 Used by the mycred_content_purchase_has_expired function.
Example

Example 1: Change the expiration length calculation from using hours to days.

Back To Top

mycred_sell_this_button

Package: mycred/content Category: Filters
Description

This filter allows you to make adjustments to the button the Sell Content add-on renders for users who have not purchased access to content set for sale. You can for example use this filter to adjust the button elements attributes or customize the button label.

Available since version 1.7

Parameters
Param Type Required Description
$button string Yes

The HTML button element.

$post obj No

The WordPress post object that this button is being rendered for.

$setup array No

An associated array of the point type setup. This is the values set in the Sell Content add-ons settings for a particular point type. Note that if multiple point types are allowed to be used as payment, this settings might differ.

$mycred obj No

The myCRED_Settings object currently being used.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Insert an icon into the buttons label.

Back To Top

mycred_sell_this_label

Package: mycred/content Category: Filters
Description

This filter allows you to rename the Sell Content metabox that is inserted into your post editor screen. As of version 1.7, this will only run if you have set to sell content using “Manual Mode”.

Available since version 1.5.3

Parameters
Param Type Required Description
$label string Yes

The metabox title string.

Used By
Package Prio. Description
mycred/content 10 Used by the myCRED_Sell_Content_Module class.

Back To Top

mycred_send_language

Package: mycred/core Category: Filters
Description

This filter allows you to change the language used when using the mycred_send shortcode. There are by default three messages that can be translated / adjusted:

  • working – used when the button is clicked and we are waiting for the AJAX call to finish.
  • done – used on successfull transactions
  • error – used on transactions that failed.

Available since version 1.3

Parameters
Param Type Required Description
$instances array Yes

An array of strings used by the mycred_send shortcode.

Used By
Package Prio. Description
mycred/core 10 Used by the mycred_send shortcode.

Back To Top

mycred_setup_addons

Package: mycred/core Category: Filters
Description

This filter allows you to register a custom add-on or remove / rename a built-in one.

When creating a custom add-on, it is not required to use this filter unless you want users to select to enable the add-on on the myCRED > Add-ons page in the admin area. If you are adding a custom add-on via a plugin, you could however make the add-on auto enable when the plugin is enabled.

Available since version 1.0

Parameters
Param Type Required Description
$addons array Yes

An associative array of add-ons installed.

Structure:

  • name – The name shown in the add-on list.
  • description – Optional description for the add-on.
  • addon_url – Optional information url.
  • version – The version of the add-on.
  • author – The add-on authors name.
  • author_url – The add-on authors url.
  • screenshot – The add-on image.
  • pro_url – Option to show a different version of the add-on via a url.

Used By
Package Prio. Description
mycred/core 10 Used by the myCRED_Addons_Module class.

Back To Top

mycred_setup_banking

Package: mycred/banking Category: Filters
Description

This filter allows you to add custom banking services or remove built-in ones. Banking services are loaded just like hooks, meaning that you will need to provide the class or function name that loads the service for the add-on to load the service once enabled by the user.

Available since version 1.2

Parameters
Param Type Required Description
$services array Yes

An associated array of installed services.

Used By
Package Prio. Description
mycred/banking 10 Used by the myCRED_Banking_Module class.
Example

Example 1: Add a custom banking service.

Back To Top

mycred_setup_hooks

Package: mycred/core Category: Filters
Description

This filter allows you to add custom hooks or remove built-in ones.

Available since version 1.0.1

Parameters
Param Type Required Description
$hooks array Yes

An associated array of installed hooks.

$point_type string No

The point type being rendered when the filter fires. This can be used which hooks are available for each point type you might have installed.

Used By
Package Prio. Description
mycred/core 10 Used by the myCRED_Hooks_Module class.
Examples

Example 1: Add a custom hook.

Example 2: Remove certain hooks from being usable for custom point types.

Back To Top

mycred_transfer_acc_limit

Package: mycred/transfer Category: Filters
Description

When a user transfers points to another user on your website, one of the checks myCRED makes it to ensure that he is solvent for the amount he wants to transfer. So by default, users can not send more points then they actually have. This filter allows you to override this and allow users to transfer more.

Available since version 1.0.8

Parameters
Param Type Required Description
$minimum int or float Yes

The lowest amount a users balance can go when transferring. Defaults to zero.

$point_type string No

The point type being transferred.

$user_id int No

The numeric ID of the user making the transfer.

$reference string No

The reference under which the transfer is being made. Usable when you allow multiple types of transfers.

Used By
Package Prio. Description
mycred/transfer 10 Used by the transfer add-on.
mycred/core 20 Used by the mycred_send shortcode processor.
Example

Example 1: Give contributors 100 points “credit“ when making a transfer.

Example 2: Allow users to transfer up to 500 points more than they have on their account when making a “donation“.

Back To Top

mycred_transfer_autofill_by

Package: mycred/transfer Category: Filters
Description

This filter allows you to add / remove autocomplete options in the Transfer add-on.

Available since version 1.6

Parameters
Param Type Required Description
$options array Yes

An associative array of autocomplete value and label that is shown in the dropdown menu.

$settings array No

The transfer add-on settings.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Add the option to disable Autocomplete in our transfer settings.

function mycred_pro_disable_autocomplete_option( $options ) {

	$options['none'] = 'Disable Autocomplete';

	return $options;

}
add_filter( 'mycred_transfer_autofill_by', 'mycred_pro_disable_autocomplete_option' );

Back To Top

mycred_transfer_messages

Package: mycred/transfer Category: Filters
Description

This filter allows you to adjust the transfer messages that the javascript uses when processing transfer requests. You can use this to adjust existing language being used or add your own.

Default messages:

  • completed – Message to show when the transfer was successfully completed.
  • error_1 – WordPress nonce has expired (page has been opened too long without running the form).
  • error_2 – Communications error (bad form submission).
  • error_3 – Recipient not found.
  • error_4 – Transaction declined by recipient (recipient is excluded from points).
  • error_5 – Incorrect amount (usually zero points or empty).
  • error_6 – Transfer add-on has not been setup.
  • error_7 – Insufficient funds.
  • error_8 – Transfer limit exceeded.
  • error_9 – Processing error (transfer declined or duplicate transfer).
  • error_10 – Selected point type not set to be transferrable.

Available since version 1.5

Parameters
Param Type Required Description
$instances array Yes

An array of strings used by the mycred_transfer shortcode.

Used By
Package Prio. Description
mycred/transfer 10 Used by the myCRED_Transfer_Module class.

Back To Top

mycred_twilio_format_phone_number

Package: mycred/twilio Category: Filters
Description

This filter allows you to adjust a given phone numbers formating.

Available since version 2.0

Parameters
Param Type Required Description
$phone_number string Yes

The phone number formatted by appending the country code and removing non numeric characters.

$number string No

The original number before formating.

$country_code string No

The country code saved in the plugin settings.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_twilio_get_sender

Package: mycred/twilio Category: Filters
Description

This filter allows you to adjust the results when the Twilio Transfer plugin tries to tie a phone number to a user on your website.

Available since version 1.0

Parameters
Param Type Required Description
$sender bool or obj Yes

Either FALSE if the user could not be found or the WordPress user object on success.

$number string No

The phone number as sent from Twilio. Example for North American numbers: +11234567890

$meta_key string No

Either the user meta key where the phone number is stored or the field name if BuddyPress is used.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_twilio_get_senders_id

Package: mycred/twilio Category: Filters
Description

This filter allows you to adjust the results when the Twilio Transfer plugin tries to tie a phone number to a user on your website.

Available since version 1.0

Parameters
Param Type Required Description
$user_id bool or int Yes

Either FALSE if the user could not be found or the numeric ID if a match is made.

$number string No

The phone number as sent from Twilio. Example for North American numbers: +11234567890

$meta_key string No

Either the user meta key where the phone number is stored or the field name if BuddyPress is used.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_twilio_get_users_number

Package: mycred/twilio Category: Filters
Description

This filter allows you to adjust the results where the Twilio Transfers plugin tries to find the phone number of a given user.

Available since version 1.0

Parameters
Param Type Required Description
$number bool or string Yes

Either FALSE if the phone number is not found or the number as it is stored in the database.

$user_id int No

The users numeric ID.

$meta_key string No

Either the user meta key where the phone number is stored or the field name if BuddyPress is used.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_twilio_parse_sms

Package: mycred/twilio Category: Filters
Description

This filter allows you to adjust the SMS message body when received by the Twilio Transfers plugin.

Available since version 2.0

Parameters
Param Type Required Description
$sms array Yes

The message body converted into an array. By default, the body content is split into 4 pieces.

$body string No

The SMS message body in it’s raw form.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_twilio_phone_number

Package: mycred/transfer Category: Filters
Description

This filter allows you to format a Twilio phone number into the way you format phone numbers on your website.

Requires SMS Payments version 2.0

Available since version 2.0

Parameters
Param Type Required Description
$number string Yes

The phone number Twilio sends. This is an unformatted phone number with the country code appended to the beginning.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Phone numbers are stored as (xxx) xxx-xxxx in our database so we convert the Twilio number to the same format

Back To Top

mycred_twilio_xml_response

Package: mycred/twilio Category: Filters
Description

This filter allows you to make adjustments to the response SMS body before it is sent to Twilio. The filter is used for all SMS responses no matter the instance.

Available since version 2.0

Parameters
Param Type Required Description
$template string Yes

The SMS message body.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Append the sites name to all sms messages sent.

Back To Top

mycred_user_has_paid_for_content

Package: mycred/content Category: Filters
Description

This filter allows you to indicate if the current user has paid / not paid for a particular content. Before a content is rendered that is set for sale using the Sell Content add-on, myCRED needs to determine if the current user has paid for the content or not. This in turn, determines if we should render the actual content or if we need to load a template asking the user to pay or buy more points (depending on your setup).

Available since version 1.4

Parameters
Param Type Required Description
$has_paid bool Yes

Either TRUE indicating the has paid and the content should be rendered or FALSE to force the user to pay to see the content.

$user_id int No

The numeric ID of the user that we are checking payment for.

$post_id int No

The post object ID that is set for sale.

$last_payment obj No

If the user has paid for the content (expired or not expired) this will contain the log entry pulled from the myCRED log. If no payment is found, this will return NULL. Added in 1.7.

Used By
Package Prio. Description
mycred/content 10 Used by the mycred_user_paid_for_content function.
Example

Example 1: Allow Authors to see content set for sale using the Sell Content add-on without having to pay.

Example 2: Allow users that has reached a specific myCRED Rank to view content that has been set for sale. Requires myCRED 1.7+

Back To Top

mycred_user_row_actions

Package: mycred/core Category: Filters
Description

This filter allows you to remove or add custom action links when viewing your users point balance on the Users page.

Available since version 1.1

Parameters
Param Type Required Description
$actions array Yes

An array of links to show in the balance column.

$user_id int No

The numeric user ID.

$mycred obj No

The myCRED_Settings object set for the particular point type being shown.

Used By
Package Prio. Description
mycred/core 10 Used by the myCRED_Management_Module class.
Example

Example 1: Add the option to reset a users balance from the Users page in your admin area. Requires myCRED 1.7.3+

Back To Top

mycred_userpro_insufficient

Package: mycred/hook Category: Filters
Description

This filter allows you to adjust the message a user sees in the chat window when they have run out of funds. Used by the UserPro Private Messaging hook.

Available since version 1.1.3

Parameters
Param Type Required Description
$message string Yes

The message to show users. Defaults to “Insufficient Funds” wrapped in a div element to be shown as a warning message.

$from int No

The numeric ID of the user sending the message.

$to int No

The numeric ID of the message recipient.

$hook obj No

The hook object.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Display a custom message with a link to users when they run out of funds (assuming you charge users for sending messages).

Back To Top

mycred_userpro_stop_message

Package: mycred/hook Category: Filters
Description

This filter allows you to stop a private message from being sent and instead trigger the “Insufficient Funds” message. Used by the UserPro Private Messaging hook.

Available since version 1.1.3

Parameters
Param Type Required Description
$response bool Yes

Return TRUE to stop the message else FALSE.

$from int No

The numeric ID of the user sending the message.

$to int No

The numeric ID of the message recipient.

$hook obj No

The hook object.

Used By
Package Prio. Description
Not used by any built-in package.

Back To Top

mycred_users_of_rank

Package: mycred/rank Category: Filters
Description

This filter allows you to adjust the template used by the mycred_users_of_rank shortcode when rendering users of a rank you have setup for a particular point type. While you can set the template when using the shortcode, this filter accomplishes the exact same task.

Available since version 1.2

Parameters
Param Type Required Description
$row_template string Yes

The row template.

$atts array No

The attributes passed to the shortcode.

$mycred obj No

The myCRED object.

Used By
Package Prio. Description
mycred/rank 10 Used by the mycred_users_of_rank shortcode.

Back To Top

mycred_users_profile_url

Package: mycred/core Category: Filters
Description

This filter allows you to adjust what URL the %user_profile_url% and the %user_profile_link% template tags point to.

By default, myCRED will use WordPress default author url setup, unless you have BuddyPress or bbPress installed, in which case, the profile URLs these plugins use are returned.

As of version 1.7.4 this filter has been moved from the myCRED_Settings class to the mycred_get_users_profile_url function.

Available since version 1.3

Parameters
Param Type Required Description
$url string Yes

The profile url string.

$user obj No

The WordPress user object.

Used By
Package Prio. Description
mycred/core 10 Used by the mycred_get_users_profile_url function.

Back To Top

mycred_video_output

Package: mycred/core Category: Filters
Description

This filter allows you to adjust the video embed that is generated by the mycred_video add-on.

Available since version 1.3.3

Parameters
Param Type Required Description
$output string Yes

The rendered shortcode content.

$atts array No

The shortcode attributes passed onto the shortcode.

Used By
Package Prio. Description
mycred/core 10 Used by the mycred_video shortcode.

Back To Top

mycred_video_query_youtube

Package: mycred/core Category: Filters
Description

This filter allows you to adjust the query that is passed on to YouTube in order to embed a video. You can find a complete list of possible values you can use in the YouTube iFrame API documentation.

Available since version 1.2

Parameters
Param Type Required Description
$args array Yes

An associative array of arguments.

$atts array No

The attributes passed on to the mycred_video shortcode.

$video_id string No

The YouTube video id.

Used By
Package Prio. Description
mycred/core 10 Used by the mycred_video shortcode.
Example

Example 1: Remove the YouTube video controller when embedding videos using the mycred_video shortcode.

Back To Top

mycred_woo_order_cost

Package: mycred/payment Category: Filters
Description

This filter allows you to adjust the point cost calculation in WooCommerce. The filter is used in two different instances in WooCommerce:

a) In Cart

When a user views their cart on both the cart page and on the checkout page, the filter is used to calculate the users cart total in points.

b) When paying using points

When a user selects to pay using points on the checkout page, the filter is used to calculate the amount of points a user must pay for the order. If the user does not have the point amount this filter returns, the payment is declined.

By default, the exchange rate you set in your settings is used to calculate the cost but you can use this filter to run your own calculation.

Available since version 1.2

Parameters
Param Type Required Description
$cost int or float Yes

The cost of the cart / order in your store currency.

$order_or_cart obj No

Either the cart object or the order object, depending on where the filter is used.

$is_cart bool No

Returns TRUE if the filter is used when showing the cart total cost in points and FALSE when calculating the cost during checkout (if the buyer selected to pay using points).

$gateway obj No

The myCRED payment gateway object.

Used By
Package Prio. Description
mycred/payment 10 Used by the myCRED payment gateway.
Example

Example 1: Apply a custom exchange rate for users with the “Author“ role. Everyone else gets the exchange rate you set in your settings.

Back To Top

mycred_woo_reward_cap

Package: mycred/payment Category: Filters
Description

This filter allow you to adjust the capability required for the “myCRED” point reward metabox to be visible when editing a WooCommerce product. By default, your users (and yourself) need to have the edit_others_posts capability to set how many points a product rewards (if at all). This capability on default WordPress installations is held by the “Administrator” and “Editor” roles.

Available since version 1.5

Parameters
Param Type Required Description
$capability string Yes

The WordPress capability required for the metabox to be accessible. This can be a custom capability as well.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Change the requirement to a capability that only Administrators have in order to prevent Editors from using it.

Back To Top

mycred_woo_reward_log

Package: mycred/hook Category: Filters
Description

This filter allows you to adjust the log entry myCRED adds with each WooCommerce store reward payout.

Available since version 1.0

Parameters
Param Type Required Description
$log_template string Yes

The log template to use.

$order_id int No

The WooCommerce order ID.

$point_type string No

The point type key, representing the point type the user is paid.

Used By
Package Prio. Description
Not used by any built-in package.
Example

Example 1: Basic Usage

/**
 * Change Woo Reward Template
 * @version 1.0
 */
function mycred_pro_adjust_woo_reward_log( $log_template, $order_id ) {

	return sprintf( 'Reward for your sore order #%d', $order_id );

}
add_filter( 'mycred_woo_reward_log', 'mycred_pro_adjust_woo_reward_log', 10, 2 );

Back To Top

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 - 2019 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.

  • 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