mycred_add
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/banking | 1 | The central banking service uses this filter to stop transactions if the central bank runs out of points. |
Example 1: Stop user 1 from gaining points for approved comments.
Example 2: Prevent your users balance from going minus.
mycred_add_finished
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.
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. |
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 1: Send an email when a user buys points using the buyCRED add-on.
mycred_affiliate_cookie
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Change the cookies lifespan from 24 hours to 1 year.
mycred_affiliate_key
This filter allows you to adjust the affiliate referral key that the hook uses. By default this is mref.
Param | Type | Required | Description |
---|---|---|---|
$key |
string | Yes | The key. Defaults to |
$hook |
obj | No | The hook object. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
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.
mycred_all_references
This filter allows you to add / remove / rename any of the built-in myCRED references.
Param | Type | Required | Description |
---|---|---|---|
$list |
array | Yes | An associative array of references that have been registered in myCRED. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Add a custom reference.
mycred_allowed_tags
This filter allows you to change the HTML elements that myCRED will allow in the history shortcode.
Param | Type | Required | Description |
---|---|---|---|
$allowed |
array | Yes | Array of HTML elements and their attributes that are allowed to be used. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Change the allowed HTML elements to only accept paragraphs and Emphasized text.
mycred_apply_exchange_rate
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.
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 |
$round |
bool | No | Indicates if the amount should be rounded (TRUE) or not (FALSE). |
Package | Prio. | Description |
---|---|---|
mycred/payment | 10 | MarketPress payment gateway. |
mycred/payment | 20 | WooCommerce payment gateway. |
mycred_badge_image
This filter allows you to adjust the badge image element before it is rendered.
Param | Type | Required | Description |
---|---|---|---|
$html |
string | Yes | The badge image element. |
$image |
int or string | No | Either |
$badge_object |
obj | No | The myCRED_Badge object. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Add a Bootstrap tooltip to all badge images except for the main badge image.
mycred_badge_user_value
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_banking_save_interest
This filter allows you to add or adjust the settings saved by the compound interest banking service.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_banking_save_recurring
This filter allows you to save custom settings you might have added to the Recurring Payout service in the Banking add-on.
Param | Type | Required | Description |
---|---|---|---|
$settings |
array | Yes | An associative array of settings for the service. |
$service |
obj | No | The Recurring Payout class object. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_bp_leaderboard_{$column_id}_column
This filter allows you to render the contents of a custom leaderboard column in the myCRED BP Group Leaderboards plugin.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Render the content of a custom leaderboard column we created with the ID “avatar“.
mycred_bp_leaderboard_columns
This filter allows you to adjust the leaderboard table columns that the myCRED BP Group Leaderboards plugin creates.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
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.
mycred_bp_leaderboard_find_position
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Example showing how we can query a users position in an annual leaderboard.
mycred_bp_leaderboard_get
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.
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. |
$fresh |
bool | No |
|
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Example of how to run a custom leaderboard query based on annual point gains.
mycred_bp_leaderboard_types
This filter allows you to adjust, add or remove leaderboards types in the myCRED BP Group Leaderboards plugin.
Param | Type | Required | Description |
---|---|---|---|
$leaderboards |
array | Yes | An associative array of leaderboard type keys and labels. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
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' );
mycred_bp_rank_in_header
This filter allows you to adjust the way ranks are rendered in the BuddyPress user profile header (if used).
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Only show the users rank title without any extra HTML elements in their profile header.
mycred_bp_rank_in_profile
This filter allows you to adjust the way ranks are rendered in the BuddyPress user profile (if used).
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Only show the users rank title without any extra HTML elements in their profile header.
mycred_buycred_get_cost
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/purchase | 10 | Used by the selected payment gateway to calculate the cost. |
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.
mycred_central_banking_ignore
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.
Param | Type | Required | Description |
---|---|---|---|
$references |
array | Yes | An Array of references that should be ignored by the central bank. Defaults to: |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
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' );
mycred_compound_max_limit
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.
Param | Type | Required | Description |
---|---|---|---|
$limit |
int | Yes | The number of balances to compound per instance. |
$service |
obj | No | The compound interest banking service object. |
Package | Prio. | Description |
---|---|---|
mycred/banking | 10 | Default usage |
mycred_compound_pay_max_limit
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/banking | 10 | Default usage |
mycred_decline_store_purchase
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Decline point payment in WooCommerce if a user does not have at least 100 point left after payment.
mycred_delete_hook_ref
This filter allows you to adjust the reference that the Points for Deleting Content hook uses when awarding / deducting points. Defaults to deleted_content
.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_em_approve_on_pay
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_email_before_send
This filter allows you to adjust the details of an email notification before it is sent.
Param | Type | Required | Description |
---|---|---|---|
$email |
array | Yes | An associative array of email details:
|
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 1: Append a footer to all emails sent by the Email Notifications add-on.
mycred_email_instances
This filter allows you to add / remove or adjust email instances that is selectable when creating or editing an email notice.
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”.
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Add a custom email instance for when a users balance reaches 1000 points. Insert the instance under the “General“ group.
mycred_exclude_user
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
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+)
mycred_export_headers
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.
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” |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_find_users_rank
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.
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. | |
)
|
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
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.
mycred_format_creds
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
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.
mycred_format_number
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Even though we use decimals, when displaying points, we always display them as integers.
mycred_get_content_price
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/content | 10 | Used by the Sell Content add-on. |
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.
mycred_get_users_cred
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Load balances that exist in a separate database table and not in the user meta table.
mycred_give_run
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.
Param | Type | Required | Description |
---|---|---|---|
$run |
bool | Yes | If the shortcode is set to run ( |
$atts |
array | No | The shortcode attributes that are being used. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Disable usage of this shortcode.
add_filter( 'mycred_give_run', '__return_false' );
mycred_has_entry
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_have_ranks
Used by the mycred_have_ranks function when checking if any ranks exists for a given point type.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_label
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.
Param | Type | Required | Description |
---|---|---|---|
$label |
string | Yes | The MYCRED_DEFAULT_LABEL value. |
Example 1: Change the myCRED plugin name to SuperPoints.
mycred_label_my_balance
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Change the template to show the word “Your Balance“ followed by the users balance.
mycred_link
This filter allows you to adjust the anchor element the mycred_link shortcode renders.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_log_{column}
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Render the content of a custom column with the id “row-id“.
mycred_log_bulk_actions
This filter allows you to adjust the bulk actions that are available on the log page in the admin area.
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 |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Remove bulk actions in the logs.
mycred_log_column_{type}_headers
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Remove the date column from the default point type only.
mycred_log_column_headers
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.
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. |
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. |
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.
mycred_log_date
This filter allows you to adjust how dates in the log or in exports are presented.
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. |
Package | Prio. | Description |
---|---|---|
mycred/log | 10 | Used by the log query class. |
mycred/log | 20 | Used by the export module. |
Example 1: Instead of showing a date for each log entry, we show time ago.
mycred_log_row_classes
This filter allows you to adjust, add or remove CSS classes for each table row when viewing the log.
Param | Type | Required | Description |
---|---|---|---|
$classes |
array | Yes | Array of CSS classes. |
$entry |
obj | No | The log entry object. |
Package | Prio. | Description |
---|---|---|
mycred/log | 10 | Used by the log query class. |
Example 1: Add custom CSS classes indicating if the entry value is positive or negative.
mycred_lotto_payout_type
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
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'; }
mycred_lotto_times12
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.
mycred_lotto_times24
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.
mycred_notice_js
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.
Param | Type | Required | Description |
---|---|---|---|
$args |
array | Yes | Associative array of arguments. |
$module |
obj | No | The myCRED Notifications Plus module object. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Disable front end debugging for administrators.
mycred_notifications
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.
Param | Type | Required | Description |
---|---|---|---|
$notifications |
array | No | Array of notifications. |
Package | Prio. | Description |
---|---|---|
mycred/notice | 10 | Used by the notification add-on to get notifications. |
mycred_notifications_note
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/notice | 10 | Used by the notification add-on. |
mycred_parse_tags_amount
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/core | 10 | Used by the myCRED_Settings class. |
Example 1: Add a custom template tag that renders the points amount with a dollar sign.
mycred_parse_tags_comment
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/core | 10 | Used by the myCRED_Settings class. |
Example 1: Add a custom comment related template tag that shows the comment authors IP when the comment was posted.
mycred_parse_tags_general
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.
Param | Type | Required | Description |
---|---|---|---|
$content |
string | Yes | The log entry string. |
Package | Prio. | Description |
---|---|---|
mycred/core | 10 | Used by the myCRED_Settings class. |
mycred_parse_tags_post
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/core | 10 | Used by the myCRED_Settings class. |
Example 1: Add a custom post related template tag showing a posts status in the log entries.
mycred_parse_tags_user
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/core | 10 | Used by the myCRED_Settings class. |
Example 1: Add a custom user related template tag showing the users avatar.
mycred_post_is_for_sale
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!
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 1: Set all content for sale that are authored by the user with the ID 123.
mycred_pt_get_fee
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
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.
mycred_publish_hook_new
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!
Param | Type | Required | Description |
---|---|---|---|
$new_statuses |
array | Yes | An array of statuses a post needs to transition to. By default these are: |
$post_id |
int | No | The post objects ID. |
$point_type |
string | No | The point type key currently being processed. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Add a custom “Archived“ post status to the “Points for publishing content“ hook in myCRED.
mycred_publish_hook_old
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!
Param | Type | Required | Description |
---|---|---|---|
$old_statuses |
array | Yes | An array of statuses a post needs to transition from. By default these are: |
$post_id |
int | No | The post objects ID. |
$point_type |
string | No | The point type key currently being processed. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Add a custom “Pre Approved“ post status to the “Points for publishing content“ hook in myCRED.
mycred_publish_hook_ref
This filter allows you to adjust the reference that the Points for Publishing Content hook uses when awarding / deducting points. Defaults to publishing_content
.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Log the event under a unique reference based on the post type being published.
mycred_query_log_args
Used by the myCRED_Query_Log class, this filter allows you to make adjustments to the query arguments before it is run by class.
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. |
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 )
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Make sure that admins and editors can only view their own manual adjustments when viewing the log.
mycred_rank_list
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/rank | 10 | Used by the mycred_list_ranks shortcode. |
Example 1: Change the template used when listing ranks via the mycred_list_ranks shortcode to render details with Bootstrap support.
mycred_ranking_row
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/log | 10 | Used by the mycred_leaderboard shortcode. |
Example 1: Add avatars to each user shown in your leaderboard.
mycred_ranking_sql
This filter allows you to adjust the MySQL query string used for generating a leaderboard through the mycred_leaderboard shortcode.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_recurring_max_limit
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.
Param | Type | Required | Description |
---|---|---|---|
$limit |
int | Yes | The number of users to execute per instance. |
$service |
obj | No | The recurring payout banking service object. |
Package | Prio. | Description |
---|---|---|
mycred/banking | 10 | Default usage |
mycred_register_ranks
This filter lets you make adjustments to the Ranks post type settings before it is handed over to the register_post_type function.
Param | Type | Required | Description |
---|---|---|---|
$args |
array | Yes | The post type settings array. |
$module |
obj | No | The myCRED_Ranks_Module class. |
Package | Prio. | Description |
---|---|---|
mycred/rank | 10 | Used by the myCRED_Ranks_Module class. |
Example 1: Change the rank post type capability.
mycred_run_this
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/core | 10 | Used by the myCRED_Settings class. |
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.
mycred_scratch_card_templates
This filter allows you to add, replace or remove templates for the Scratch Card add-on.
Param | Type | Required | Description |
---|---|---|---|
$templates |
array | Yes | An associative array of available templates. You can read more about this in the Scratch Card documentation. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Add a custom template from a theme.
Example 2: Add a custom template from a plugin.
mycred_scratch_everyonewins
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.
Param | Type | Required | Description |
---|---|---|---|
$allow |
bool | Yes |
|
$set_id |
int | No | The card sets WordPress post ID. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Enable all cards to be winning cards.
add_filter( 'mycred_scratch_everyonewins', '__return_true' );
mycred_sell_content_priority
This filter allows you to change the priority of the Sell Content add-ons content filtering.
Param | Type | Required | Description |
---|---|---|---|
$priority |
int | Yes | The priority number. Defaults to |
$sell_content_module |
obj | No | The Sell Content module. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Lower the priority of the content filter.
mycred_sell_exp_title
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.
Param | Type | Required | Description |
---|---|---|---|
$label |
string | No | The title to show. |
Package | Prio. | Description |
---|---|---|
mycred/content | 10 | Used by the Sell Content add-on. |
Example 1: Change the Expiration Label.
mycred_sell_expire_calc
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/content | 10 | Used by the mycred_content_purchase_has_expired function. |
Example 1: Change the expiration length calculation from using hours to days.
mycred_sell_this_button
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Insert an icon into the buttons label.
mycred_sell_this_label
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”.
Param | Type | Required | Description |
---|---|---|---|
$label |
string | Yes | The metabox title string. |
Package | Prio. | Description |
---|---|---|
mycred/content | 10 | Used by the myCRED_Sell_Content_Module class. |
mycred_send_language
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 transactionserror
– used on transactions that failed.
Param | Type | Required | Description |
---|---|---|---|
$instances |
array | Yes | An array of strings used by the mycred_send shortcode. |
Package | Prio. | Description |
---|---|---|
mycred/core | 10 | Used by the mycred_send shortcode. |
mycred_setup_addons
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.
Param | Type | Required | Description |
---|---|---|---|
$addons |
array | Yes | An associative array of add-ons installed. Structure:
|
Package | Prio. | Description |
---|---|---|
mycred/core | 10 | Used by the myCRED_Addons_Module class. |
mycred_setup_banking
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.
Param | Type | Required | Description |
---|---|---|---|
$services |
array | Yes | An associated array of installed services. |
Package | Prio. | Description |
---|---|---|
mycred/banking | 10 | Used by the myCRED_Banking_Module class. |
Example 1: Add a custom banking service.
mycred_setup_hooks
This filter allows you to add custom hooks or remove built-in ones.
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. |
Package | Prio. | Description |
---|---|---|
mycred/core | 10 | Used by the myCRED_Hooks_Module class. |
Example 1: Add a custom hook.
Example 2: Remove certain hooks from being usable for custom point types.
mycred_transfer_acc_limit
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/transfer | 10 | Used by the transfer add-on. |
mycred/core | 20 | Used by the mycred_send shortcode processor. |
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“.
mycred_transfer_autofill_by
This filter allows you to add / remove autocomplete options in the Transfer add-on.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
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' );
mycred_transfer_messages
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.
Param | Type | Required | Description |
---|---|---|---|
$instances |
array | Yes | An array of strings used by the mycred_transfer shortcode. |
Package | Prio. | Description |
---|---|---|
mycred/transfer | 10 | Used by the myCRED_Transfer_Module class. |
mycred_twilio_format_phone_number
This filter allows you to adjust a given phone numbers formating.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_twilio_get_sender
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.
Param | Type | Required | Description |
---|---|---|---|
$sender |
bool or obj | Yes | Either |
$number |
string | No | The phone number as sent from Twilio. Example for North American numbers: |
$meta_key |
string | No | Either the user meta key where the phone number is stored or the field name if BuddyPress is used. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_twilio_get_senders_id
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.
Param | Type | Required | Description |
---|---|---|---|
$user_id |
bool or int | Yes | Either |
$number |
string | No | The phone number as sent from Twilio. Example for North American numbers: |
$meta_key |
string | No | Either the user meta key where the phone number is stored or the field name if BuddyPress is used. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_twilio_get_users_number
This filter allows you to adjust the results where the Twilio Transfers plugin tries to find the phone number of a given user.
Param | Type | Required | Description |
---|---|---|---|
$number |
bool or string | Yes | Either |
$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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_twilio_parse_sms
This filter allows you to adjust the SMS message body when received by the Twilio Transfers plugin.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_twilio_phone_number
This filter allows you to format a Twilio phone number into the way you format phone numbers on your website.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Phone numbers are stored as (xxx) xxx-xxxx in our database so we convert the Twilio number to the same format
mycred_twilio_xml_response
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.
Param | Type | Required | Description |
---|---|---|---|
$template |
string | Yes | The SMS message body. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Append the sites name to all sms messages sent.
mycred_user_has_paid_for_content
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).
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. |
Package | Prio. | Description |
---|---|---|
mycred/content | 10 | Used by the mycred_user_paid_for_content function. |
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+
mycred_user_row_actions
This filter allows you to remove or add custom action links when viewing your users point balance on the Users page.
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. |
Package | Prio. | Description |
---|---|---|
mycred/core | 10 | Used by the myCRED_Management_Module class. |
Example 1: Add the option to reset a users balance from the Users page in your admin area. Requires myCRED 1.7.3+
mycred_userpro_insufficient
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Display a custom message with a link to users when they run out of funds (assuming you charge users for sending messages).
mycred_userpro_stop_message
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.
Param | Type | Required | Description |
---|---|---|---|
$response |
bool | Yes | Return |
$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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
mycred_users_of_rank
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/rank | 10 | Used by the mycred_users_of_rank shortcode. |
mycred_users_profile_url
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.
Param | Type | Required | Description |
---|---|---|---|
$url |
string | Yes | The profile url string. |
$user |
obj | No | The WordPress user object. |
Package | Prio. | Description |
---|---|---|
mycred/core | 10 | Used by the mycred_get_users_profile_url function. |
mycred_video_output
This filter allows you to adjust the video embed that is generated by the mycred_video add-on.
Param | Type | Required | Description |
---|---|---|---|
$output |
string | Yes | The rendered shortcode content. |
$atts |
array | No | The shortcode attributes passed onto the shortcode. |
Package | Prio. | Description |
---|---|---|
mycred/core | 10 | Used by the mycred_video shortcode. |
mycred_video_query_youtube
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/core | 10 | Used by the mycred_video shortcode. |
Example 1: Remove the YouTube video controller when embedding videos using the mycred_video shortcode.
mycred_woo_order_cost
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.
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. |
Package | Prio. | Description |
---|---|---|
mycred/payment | 10 | Used by the myCRED payment gateway. |
Example 1: Apply a custom exchange rate for users with the “Author“ role. Everyone else gets the exchange rate you set in your settings.
mycred_woo_reward_cap
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.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
Example 1: Change the requirement to a capability that only Administrators have in order to prevent Editors from using it.
mycred_woo_reward_log
This filter allows you to adjust the log entry myCRED adds with each WooCommerce store reward payout.
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. |
Package | Prio. | Description |
---|---|---|
Not used by any built-in package. |
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 );