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.

Last edited June 23, 2016

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.

Last edited June 23, 2016

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.

Last edited June 24, 2016

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.

Last edited September 2, 2016

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.

Last edited June 24, 2016

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.

Last edited June 24, 2016

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.

Last edited June 23, 2016

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.

Last edited July 26, 2016

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.

Last edited June 24, 2016

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.

Last edited June 24, 2016

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.

Last edited June 24, 2016

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.

Last edited June 23, 2016

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

Last edited July 26, 2016

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

Last edited July 26, 2016

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.

Last edited June 24, 2016

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.

Last edited June 24, 2016

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.

Last edited June 24, 2016

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.

Last edited June 24, 2016

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.

Last edited June 24, 2016

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.

Last edited June 25, 2016

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.

Last edited June 25, 2016

Back To Top

mycred_format_number

Package: mycred/balance Category: Filters

Description

Used by the myCRED_Settings class to convert string based point values into either Integers or Floats, based on the number of decimals the point type uses. Mainly used internally before 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.

Last edited June 25, 2016

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.

Last edited August 30, 2016

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.

Last edited June 25, 2016

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.

Last edited June 26, 2016

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.

Last edited June 26, 2016

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.

Last edited June 26, 2016

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.

Last edited June 26, 2016

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

Last edited June 26, 2016

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.

Last edited June 27, 2016

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.

Last edited June 26, 2016

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.

Last edited June 26, 2016

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.

Last edited August 5, 2016

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.

Last edited August 5, 2016

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

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';
}

Last edited March 28, 2016

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.

Last edited June 26, 2016

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.

Last edited June 26, 2016

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.

Last edited August 5, 2016

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.

Last edited August 5, 2016

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.

Last edited August 5, 2016

Back To Top

mycred_parse_tags_comment

Package: mycred/log Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

This filter lets you add support for custom comment related template tags or override the default ones.

These template tags are only used in the “Points for Commenting” hook by default and contains template tags for the most commonly required comment details.

Used By

Parameters

  • content (string)
    The content containing template tags.
    Remember to always return the content once you are done!
  • comment (object)
    The comment object.
    Note! If the comment has been deleted you will only have access to $comment->comment_ID and $comment->comment_post_ID.
  • data (array|string)
    If parsing the myCRED Log, the data column is passed on here. Else it will contain an empty string.

Example

Add a new template tag %IP% which will return the IP address of the comment author.

add_filter( 'mycred_parse_tags_comment', 'my_custom_comment_template_tags', 10, 3 );
function my_custom_comment_template_tags( $content, $comment, $data )
{
	$content = str_replace( '%IP%', $comment->comment_author_IP, $content );
	return $content;
}

Add this code to your themes functions.php file

Last edited June 26, 2016

Back To Top

mycred_parse_tags_general

Package: mycred/log Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

This filter lets you add support for custom General template tags or override the default ones.

Used By

Parameters

  • content (string)
    The content containing template tags.
    Remember to always return the content once you are done!

Example

Add a new template tag %register_url% which will return a link to your websites default registration page.

add_filter( 'mycred_parse_tags_general', 'my_custom_general_template_tags' );
function my_custom_general_template_tags( $content )
{
	$content = str_replace( '%register_url%', get_bloginfo( 'url' ) . '/wp-login.php?action=register', $content );
	return $content;
}

Add this code to your themes functions.php file

Last edited June 26, 2016

Back To Top

mycred_parse_tags_post

Package: mycred/log Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

This filter lets you add support for custom post related template tags or override the default ones.

Post related template tags are used when there is a reference to a post id allowing us to grab that posts details and build template tags like %link_with_title% which will return the permalink to the given post.

Used By

Parameters

  • content (string)
    The content containing template tags.
    Remember to always return the content once you are done!
  • post (object)
    The post object.
    Note! If the post has been deleted you will only have access to $post->ID, $post->post_title and $post->post_type.
  • data (array|string)
    If parsing the myCRED Log, the data column is passed on here. Else it will contain an empty string.

Example

Add a new template tag %post_status% which will return the given post’s current status.

add_filter( 'mycred_parse_tags_post', 'my_custom_post_template_tags', 10, 3 );
function my_custom_post_template_tags( $content, $post, $data )
{
	$content = str_replace( '%post_status%', $post->post_status, $content );
	return $content;
}

Add this code to your themes functions.php file

Last edited June 26, 2016

Back To Top

mycred_parse_tags_user

Package: mycred/log Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

This filter lets you add support for custom user related template tags or override the default ones.

This filter is also used by for example the Rankings Add-on to add new custom template tags for rank names and logos.

Used By

Parameters

  • content (string)
    The content containing template tags.
    Remember to always return the content once you are done!
  • user (object)
    The user object.
    Note! If the user has been deleted you will only have access to $user->ID, $user->user_login and $user->display_name.
  • data (array|string)
    If parsing the myCRED Log, the data column is passed on here. Else it will contain an empty string.

Example

Add two new template tags %avatar_small% and %avatar_large%, which will return given users avatar either in a smaller version ( 32px by 32px ) or a larger version ( 64px by 64px ).

add_filter( 'mycred_parse_tags_user', 'my_custom_user_template_tags', 10, 3 );
function my_custom_user_template_tags( $content, $user, $data )
{
	$content = str_replace( '%avatar_small%', get_avatar( $user->ID, 32 ), $content );
	$content = str_replace( '%avatar_large%', get_avatar( $user->ID, 64 ), $content );
	return $content;
}

Add this code to your themes functions.php file

Last edited June 26, 2016

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.

Last edited June 26, 2016

Back To Top

mycred_rank_list

Package: mycred/rank Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

This filter allows you to filter the row template for the mycred_list_ranks shortcode. If you find yourself using the same row template over and over again, this filter could adjust it for you automatically.

Requires myCRED 1.1 and Ranks Add-on to be enabled.

Used By

Parameters

  • template (string)
    Either the default shortcode template or the custom template.
  • atts (array)
    The shortcode attributes.
  • mycred (object)
    The myCRED Settings Object.

Example

If the shortcode attribute ‘wrap’ is set to ‘ul’, replace the given template with our own custom template.

add_filter( 'mycred_rank_list', 'customize_shortcode_template', 10, 3 );
function customize_shortcode_template( $template, $atts, $mycred )
{
	if ( $atts['wrap'] == 'ul' ) {
		return '<li>%rank_logo%<h1>%rank%</h1></li>';
	}
	return $template;
}

Last edited June 26, 2016

Back To Top

mycred_ranking_row

Package: mycred/log Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Examples

Description

This filter allows you to customize what is shown on each row in the leaderboard. You can use this to adjust layout by inserting custom HTML elements or by adding in custom details like a users avatar.

Important! Remember that this is a filter so you must always return a result!

Used By

  • Function: mycred_render_shortcode_leaderboard()

Parameters

  • layout (string)
    The leaderboard row content. This is where template tags would be inserted.
  • template (string)
    The template either sent via the shortcode or set via preferences.
  • row (object)
    The database row currently being parsed. The user fields that were requested in the db query are included here. Default user fields:
  • ID The users ID.
  • user_login The users login (username).
  • user_email The users email address.
  • user_nicename The users nicename (if used).
  • display_name The users display name.
  • user_url The users set website URL.
  • cred The balance / credit sum.

 

  • position (int)
    The users position in the leaderboard.

 

Examples

Example 1: Add the custom template tag %avatar% allowing us to show each users avatar.

add_filter( 'mycred_ranking_row', 'mycredpro_rankings_row_avatar', 10, 4 );
function mycredpro_rankings_row_avatar( $layout, $template, $user, $position ) {

	if ( isset( $user->ID ) )
		$user_id = $user->ID;
	elseif ( isset( $user['ID'] ) )
		$user_id = $user['ID'];
	else
		return $layout;

	$avatar = get_avatar( $user_id, 32 );
	return str_replace( '%avatar%', $avatar, $layout );

}

Example 2: Add a custom template tag that returns a user meta detail.

add_filter( 'mycred_ranking_row', 'mycredpro_rankings_row_meta', 10, 4 );
function mycredpro_rankings_row_meta( $layout, $template, $row, $position ) {

	if ( isset( $user->ID ) )
		$user_id = $user->ID;
	elseif ( isset( $user['ID'] ) )
		$user_id = $user['ID'];
	else
		return $layout;

	$meta = get_user_meta( $user_id, 'meta_key', true );
	return str_replace( '%meta%', $meta, $layout );

}

Last edited October 10, 2016

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.

Last edited September 9, 2016

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

Last edited July 26, 2016

Back To Top

mycred_register_ranks

Package: mycred/rank Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

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

Available since myCRED version 1.1.1

 

Used By

  • Class: myCRED_Settings Method: allowed_tags()
  • Class: myCRED_Ranks Method: register_post_type()

 

Parameters

  • args (array)
    The post type arguments for ‘mycred_rank’.

 

Example

Change the post type capability setting from the default ‘page’ to ‘post’.

<?php
add_filter( 'mycred_register_ranks', 'customize_mycred_ranks' );
function customize_mycred_ranks( $args )
{
	$args['capability_type'] = 'post';
	return $args;
}
?>

Last edited June 26, 2016

Back To Top

mycred_remove_transfer_css

Package: mycred/transfer Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

This filter lets you disable the default CSS styling for the Transfer shortcode.

Note! Only available if the Transfer Add-on is enabled.

 

Used By

  • Class: myCRED_Transfer_Creds Method: front_enqueue()

 

Parameters

  • run (boolean)
    Return false to disable the css styling. Defaults to true.

 

Example

Disable the CSS Styling

add_filter( 'mycred_remove_transfer_css', 'disable_mycred_transfer_styling' );
function disable_mycred_transfer_styling() { return false; }

Add this code to your themes functions.php file

Last edited June 26, 2016

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 No

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
Not used by any built-in package.

Examples

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

add_filter( 'mycred_run_this', 'mycred_pro_balance_adjustment_multiply', 10, 2 );
function mycred_pro_balance_adjustment_multiply( $request, $mycred ) {

	// Get the user ID
	$user_id = absint( $request['user_id'] );

	// Ignore admins
	if ( user_can( $user_id, 'promote_users' ) ) return $request;

	// If user is an editor, quadruple the amount
	if ( user_can( $user_id, 'moderate_comments' ) )
		$request['amount'] = $request['amount'] * 4;

	// If user is a author, triple the amount
	elseif ( user_can( $user_id, 'publish_posts' ) )
		$request['amount'] = $request['amount'] * 3;

	// If user is a contributor, double the amount
	elseif ( user_can( $user_id, 'edit_posts' ) )
		$request['amount'] = $request['amount'] * 2;

	return $request;

}

Last edited September 1, 2016

Back To Top

mycred_sale_history_row

Package: mycred/content Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

This filter allows you to adjust and/or add information to each row presented via the mycred_sale_history shortcode.

Used By

  • Class: myCRED_Sell_Content_Module Method: render_sales_history()

Parameters

  • row (string)
    The row string. myCRED will insert the post title with a link and the date of the purchase by default.
  • log_entry (object)
    An log entry object containing the time, amount paid, user id, post id, author id, log entry and reference.

Example

Example 1: Append the post type to the end of each row.

<?php
add_filter( 'mycred_sale_history_row', 'my_custom_tags', 10, 2 );
function my_custom_tags( $row, $entry )
{
	return $row . ' Post Type: ' . get_post_type( $entry->ref_id );
}
?>

Last edited June 26, 2016

Back To Top

mycred_sell_exp_title

Package: mycred/content Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

This filter lets your 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.

Requires the Sell Content Add-on to be enabled.

 

Used By

  • Class: myCRED_Sell_Content Method: module_init()

 

Parameters

  • title (string)
    Title of time measurement. Defaults to “Hours”.

 

Example

Instead of Hours, use Days.

// Update title
add_filter( 'mycred_sell_exp_title', 'adjust_expiration_length_title' );
function adjust_expiration_length_title() { return 'Days'; }

Add this code to your themes functions.php file or in your plugin.

Last edited June 26, 2016

Back To Top

mycred_sell_expire_calc

Package: mycred/content Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

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.

Requires the Sell Content Add-on to be enabled.

 

Used By

  • Class: myCRED_Sell_Content Method: purchase_has_expired()

 

Parameters

  • expire (int)
    The number of seconds in which the content expires. Defaults to length x 3600 seconds.
  • length (int)
    The expiration length. For example 1 hour or 30 days.
  • user_id (int)
    The user who is purchasing the content.
  • post_id (int)
    The post id.

 

Example

Instead of Hours, use Days.

// Adjust calculation
add_filter( 'mycred_sell_expire_calc', 'adjust_expiration_length', 10, 4 );
function add_sitename_before_email_subject( $expire, $length, $user_id, $post_id )
{
	// Length x seconds in a day
	return abs( $length*86400 );
}
// Update title
add_filter( 'mycred_sell_exp_title', 'adjust_expiration_length_title' );
function adjust_expiration_length_title() { return 'Days'; }

Add this code to your themes functions.php file or in your plugin.

Last edited June 26, 2016

Back To Top

mycred_sell_this_label

Package: mycred/content Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

This filter allows you to rename the “myCRED Sell This” metabox that the Sell Content add-on provides for your posts and pages.

Requires myCRED 1.5.3 or higher.

Used By

  • Class: myCRED_Sell_Content_Module Method: add_metabox()

Parameters

  • title (string)
    The metabox title.
  • sell_content_module (object)
    The sell content add-on module object.

Example

Example: Rename the box to “Sell Access”.

add_filter( 'mycred_sell_this_label', 'mycred_rename_sell_this_metabox' );
function mycred_rename_sell_this_metabox( $title ) {

	return 'Sell Access';

}

Last edited June 26, 2016

Back To Top

mycred_send_language

Package: mycred/email Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This filter lets you change the language used for the button in the mycred_send shortcode.

 

Used By

 

Parameters

  • language (array)
    Associative array of button labels. Available button labels:
    • working
      Text to use when the send button has been clicked and the request is being processed. Defaults to “Processing…”.
    • done
      Text to show when the transfer was successful. Defaults to “Sent”.
    • error
      Text to show on communication error. Defaults to “Error – Try Again”.

Last edited June 26, 2016

Back To Top

mycred_setup_addons

Package: mycred/core Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Examples

Description

This filter allows you to register your own add-ons or remove/disable existing add-ons.

 

Used By

  • Class: myCRED_Addons Method: get()

 

Parameters

  • installed (array)
    Associative array of installed add-ons.

 

Examples

Example 1: Add a custom add-on.

<?php
add_filter( 'mycred_setup_addons', 'add_my_custom_addon' );
function add_my_custom_addon( $installed )
{
	$installed['plugin-folder-name'] = array(
		'title'       => __( 'My Custom Addon' ),
		'addon_uri'   => 'http://myaddon.com/',
		'version'     => '1.0',
		'description' => 'My custom add-on description.',
		'author'      => 'My Name',
		'author_uri'  => 'http://mywebsite.com',
		'file'        => 'the-file-to-include.php',
		'folder'      => 'wp-content/plugins/plugin-folder-name/',
	);

	return $installed;
}
?>

Example 2: Remove the “BuddyPress” Add-on.

<?php
add_filter( 'mycred_setup_addons', 'remove_an_addon' );
function remove_an_addon( $installed )
{
	unset( $installed['buddypress'] );
	return $installed;
}
?>

Last edited June 26, 2016

Back To Top

mycred_setup_banking

Package: mycred/banking Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

This filter allows you to register your own banking services or remove/disable existing services.

 

Used By

  • Class: myCRED_Banking Method: get()

 

Parameters

  • services (array)
    Associative array of installed services.

 

Example

Example 1: Add a custom service.

<?php
add_filter( 'mycred_setup_banking', 'add_my_custom_bank_service' );
function add_my_custom_bank_service( $services )
{
	$services['my_custom_service'] = array(
		'title'       => __( 'My Custom Service' ), // Service title
		'description' => __( 'This is a custom service' ), // Description (optional)
		'callback'    => array( 'My_Custom_Service_Class' ) // Class name
	);

	return $services;
}
?>

Example 2: Remove the “Compound Interest” Service.

<?php
add_filter( 'mycred_setup_banking', 'remove_a_service' );
function remove_a_service( $services )
{
	unset( $services['interest'] );
	return $services;
}
?>

Last edited June 26, 2016

Back To Top

mycred_setup_hooks

Package: mycred/core Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

This filter allows you to register your own hooks or remove/disable existing hooks.

 

Used By

  • Class: myCRED_Hooks Method: get()

 

Parameters

  • installed (array)
    Associative array of installed hooks.

 

Example

Example 1: Add a custom hook.

<?php
add_filter( 'mycred_setup_hooks', 'add_my_custom_hook' );
function add_my_custom_hook( $installed )
{
	$installed['my_custom_hook'] = array(
		'title'       => __( 'My Custom Hook' ), // Hook title
		'description' => __( 'This is a custom hook' ), // Description (optional)
		'callback'    => array( 'My_Custom_Hook_Class' ) // Class name
	);

	return $installed;
}
?>

Example 2: Remove the “Registration” Hook.

<?php
add_filter( 'mycred_setup_hooks', 'remove_a_hook' );
function remove_a_hook( $installed )
{
	unset( $installed['registration'] );
	return $installed;
}
?>

Last edited June 26, 2016

Back To Top

mycred_transfer_acc_limit

Package: mycred/transfer Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

By default a user can not transfer points if their balance is zero. You can change this though this filter allowing for users to go minus.

Note! Requires myCRED 1.0.8 or higher.

Used By

  • Function: mycred_user_can_transfer()

Parameters

  • amount (int|float)
    The amount to check against. If a users balance is lower or equal to this value, the transfer add-on will decline the transaction. Defaults to zero.
  • type (string)
    The point type being transferred. Added in 1.5.
  • user_id (int)
    The ID of the user making the transfer (the sender). Added in 1.6.2.
  • ref (string)
    The reference used for the transfer. Added in 1.6.2.

Example

Example: Allow users accounts to go minus 100 when transferring points.

add_filter( 'mycred_transfer_acc_limit', 'adjust_transfer_account_limit' );
function adjust_transfer_account_limit()
{
	return 0-100;
}

The above code goes in your themes functions.php file.

Last edited June 26, 2016

Back To Top

mycred_transfer_messages

Package: mycred/transfer Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This filter lets you customise all myCRED messages that the Transfer Add-on displays, depending on the outcome of a transfer.

 

Used By

  • Class: myCRED_Transfer_Creds Method: front_footer()

 

Parameters

  • messages (array)
    Associative array of all possible system messages for Points Transfers. Message keys and values:
    • completed
      Default message: “Transaction completed.”
      Trigger: Message for successful transfers.
    • error_1
      Default message: “Security token could not be verified. Please contact your site administrator!”
      Trigger: Nonce could not be verified. Either the nonce key was lost when the request was made or this is an illicit transfer attempt.
    • error_2
      Default message: “Communications error. Please try again later.”
      Trigger: Communication error. Parts of required form fields are missing and the transfer can not be executed.
    • error_3
      Default message: “Recipient not found. Please try again.”
      Trigger: The transfer recipient could not be found. Either deleted or the username is incorrect.
    • error_4
      Default message: “Transaction declined by recipient.”
      Trigger: The transfer recipient is set to be “Excluded” from using myCRED hence they can not receive points.
    • error_5
      Default message: “Incorrect amount. Please try again.”
      Trigger: The transfer amount seems to be zero. You can not transfer zero points.
    • error_6
      Default message: “This myCRED Add-on has not yet been setup! No transfers are allowed until this has been done!”
      Trigger: The Transfer Add-on has not been setup yet. Settings that are required to process transactions are missing.
    • error_7
      Default message: “Insufficient funds. Please enter a lower amount.”
      Trigger: The senders balance is to low to transfer the requested amount.
    • error_8
      Default message: “Transfer Limit exceeded.”
      Trigger: The user has reaches their transfer limit or will exceed their limit with the requested amount.

Last edited June 26, 2016

Back To Top

mycred_user_has_paid_for_content

Package: mycred/content Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This filter allows you to adjust the check myCRED makes to see if a user has paid for a content that is set for sale using the Sell Content add-on. You can use this filter to give access to specific users for specific posts without them having to pay.

Used By

  • Class: myCRED_Sell_Content_Module Method: user_paid()

Parameters

  • result (bool)
    By default will always return false.
  • user_id (int)
    The user in question, usually the current user.
  • post_id (int)
    The post in question that is set for sale.

Last edited March 28, 2016

Back To Top

mycred_user_row_actions

Package: mycred/balance Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

This filter allows you to adjust myCRED row actions for the user balance column under “Users” in the admin area.

 

Used By

  • Class: myCRED_Admin Method: custom_user_column_content()

 

Parameters

  • actions (array)
    Associative array of actions. By default actions are “History” and “Adjust”.
  • user_id (int)
    User ID.
  • mycred (int)
    The myCRED_Settings Class object.

 

Example

Example 1: Add a new action called “Reset” which resets a users balance if it is higher then 0.

<?php
// Add action
add_filter( 'mycred_user_row_actions', 'my_custom_row_action', 10, 3 );
function my_custom_row_action( $actions, $user_id, $mycred )
{
	if ( $mycred->get_users_cred( $user_id ) > $mycred->format_number( 0 ) ) {
		$args = array(
			'action'  => 'reset-points',
			'user_id' => $user_id,
			'token'   => wp_create_nonce( 'reset-users-balance' )
		);

		$url = add_query_arg( $args, admin_url( 'users.php' ) );
		$actions['reset'] = '<a href="' . $url . '">' . __( 'Reset' ) . '</a>';
	}
	return $actions;
}

// Handle action
add_action( 'admin_init', 'handle_row_action' );
function handle_row_action()
{
	if ( isset( $_GET['action'] ) && isset( $_GET['token'] ) && isset( $_GET['user_id'] ) ) {
		if ( $_GET['action'] != 'reset-points' ) return;

		$mycred = mycred_get_settings();
		$cui = get_current_user_id();

		if ( !$mycred->can_edit_creds( $cui ) ) return;
		if ( wp_verify_nonce( $_GET['token'], 'reset-users-balance' ) ) {
			$balance = $mycred->get_users_cred( $_GET['user_id'] );
			$balance = $mycred->number( 0-$balance );
			$entry = __( 'Account reset by admin.' );
			$mycred->add_creds( 'reset', $_GET['user_id'], $balance, $entry, $cui );
			add_action( 'admin_notices', 'my_admin_notice' );
		}
	}
}

// Add notice if successful
function my_admin_notice() { ?>
	<div class="updated">
		<p><?php _e( 'Users account was successfully reset.' ); ?></p>
	</div>
<?php
}
?>

Last edited March 5, 2016

Back To Top

mycred_users_of_all_ranks

Package: mycred/rank Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Example

Description

This filter allows you to filter the row template for the mycred_users_of_all_ranks shortcode. If you find yourself using the same row template over and over again, this filter could adjust it for you automatically.

Requires myCRED 1.1 and Ranks Add-on to be enabled.

 

Used By

 

Parameters

  • template (string)
    Either the default shortcode template or the custom template.
  • atts (array)
    The shortcode attributes.
  • mycred (object)
    The myCRED Settings Object.

 

Example

If the shortcode attribute ‘wrap’ is set to ‘ul’, replace the given template with our own custom template.

add_filter( 'mycred_users_of_all_ranks', 'customize_shortcode_template', 10, 3 );
function customize_shortcode_template( $template, $atts, $mycred )
{
	if ( $atts['wrap'] == 'ul' ) {
		return '<li>%rank_logo%<h1>%rank%</h1></li>';
	}
	return $template;
}

Last edited June 26, 2016

Back To Top

mycred_users_of_rank

Package: mycred/rank Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Examples

Description

This filter allows you to filter the row template for the mycred_users_of_rank shortcode. If you find yourself using the same row template over and over again, this filter could adjust it for you automatically.

Requires myCRED 1.1 and Ranks Add-on to be enabled.

 

Used By

 

Parameters

  • template (string)
    Either the default shortcode template or the custom template.
  • atts (array)
    The shortcode attributes.
  • mycred (object)
    The myCRED Settings Object.

 

Examples

Example 1: If the shortcode attribute ‘wrap’ is set to ‘ul’, replace the given template with our own custom template.

add_filter( 'mycred_users_of_rank', 'customize_shortcode_template', 10, 3 );
function customize_shortcode_template( $template, $atts, $mycred )
{
	if ( $atts['wrap'] == 'ul' ) {
		return '<li>%rank_logo%<h1>%rank%</h1></li>';
	}
	return $template;
}

Example 2: Add support for post related template tags.

add_filter( 'mycred_users_of_rank', 'customize_shortcode_template', 10, 3 );
function customize_shortcode_template( $template, $atts, $mycred )
{
	$post_id = $GLOBALS['post']->ID;
	$template = $mycred->template_tags_post( $template, $post_id );
	return $template;
}

Last edited June 26, 2016

Back To Top

mycred_users_profile_url

Package: mycred/balance Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Examples

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 the username (urlencoded) combined with the WordPress author base as the URL but you can change this to anything using this filter.

Requires myCRED 1.3 or higher.

Used By

  • Class: myCRED_Settings Method: template_tags_user()

Parameters

  • url (string)
    The URL address.
  • user (object)
    The user object.

Examples

Example 1: Use a custom URL structure www.mysite.com/members/username/.

add_filter( 'mycred_users_profile_url', 'mycred_pro_adjust_user_profile_url', 10, 2 );
function mycred_pro_adjust_user_profile_url( $url, $user ) {

	// Adjust the URL
	$url = get_bloginfo( 'url' ) . '/members/' . urlencode( $user->user_nicename ) . '/';
	return $url;

}

Example 2: Replace empty spaces in the username with a hyphen.

add_filter( 'mycred_users_profile_url', 'mycred_pro_adjust_user_profile_url', 10, 2 );
function mycred_pro_adjust_user_profile_url( $url, $user ) {

	// Adjust the URL
	$username = str_replace( ' ', '-', $user->user_login );

	// Adjust the URL
	global $wp_rewrite;
	$url = get_bloginfo( 'url' ) . '/' . $wp_rewrite->author_base . '/' . $username . '/';
	return $url;

}

Last edited December 5, 2016

Back To Top

mycred_video_embed_args

Package: mycred/core Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Default Arguments

Description

This filter allows you to adjust the swfobject embedding. The array passed though this array is imploded and inserted into swfobject.embedSWF().

Note This filter was removed in 1.3.3.

 

Used By

  • Function: mycred_render_shortcode_video

 

Parameters

  • args (array)
    Default embed arguments.
  • atts (array)
    The shortcode attributes.

 

Default Arguments

The following default arguments are passed though this filter:

array(
	'"' . $url . '"',
	'"' . $video_id . '"',
	'"' . $width . '"',
	'"' . $height . '"',
	'"9.0.0"',
	'null',
	'null',
	'{ allowScriptAccess: "always", wmode: "transparent" }',
	'null'
)

For more information consult the swfobject documentation.

Last edited June 26, 2016

Back To Top

mycred_video_output

Package: mycred/core Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This filter lets you customize the returned output of the mycred_video shortcode.

This output contains three things:

Before 1.3.3
  • The Flash Video Player embed.
  • The video state function, which is used to communicate with myCRED to award points.
After 1.3.3
  • The video Iframe.
  • The video state function, which is used by the video API to report video states and actions.
  • If enabled the update notice wrapper.

 

Used By

  • Function: mycred_render_shortcode_video

 

Parameters

  • output (string)
    The shortcode output.
  • atts (array)
    The shortcode attributes.
  • embed_args (array)
    Embed arguments. (Removed in 1.3.3)
  • video_id (string)
    YouTube Video ID. (Removed in 1.3.3)

Last edited June 26, 2016

Back To Top

mycred_video_query

Package: mycred/core Category: Filters

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Default Arguments
  5. Example

Description

This filter allows you to make changes to the youtube video query.

 

Used By

  • Function: mycred_render_shortcode_video

 

Parameters

  • args (array)
    Default YouTube Query arguments.
  • atts (array)
    The shortcode attributes.
  • video_id (string)
    YouTube Video ID.

 

Default Arguments

The following default arguments are passed though this filter:

array(
	'enablejsapi' => 1,
	'version'     => 3,
	'playerapiid' => $video_id,
	'rel'         => 0,
	'controls'    => 1,
	'showinfo'    => 0
)

For more information consult the YouTube API documentation.

 

Example

Example 1: Disable YouTube Video controls.

<?php
add_filter( 'mycred_video_query', 'customize_youtube_query' );
function customize_youtube_query( $args )
{
	$args['controls'] = 0;
	return $args;
}
?>

Last edited June 26, 2016

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

Parameters

Param Type Required Description
$cost - 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.

Last edited August 11, 2016

Back To Top

Last edited June 5, 2016