Docly Child

Actions

Estimated reading: 16 minutes 288 views

mycred_add_menu

Package: mycred/core

Category: Actions

Description

This action indicates the instance where myCRED has finished registering all the wp-admin screens. When you want to add a sub menu page for myCRED, it is recommended that you use this action hook to register your screen. This way, your screen will only be added if myCRED is enabled. 

Available since version 1.0

Parameters

Param Type Required Description
$mycred obj No

The myCRED object.

Used By

Package Prio. Description
mycred/log 10 The myCRED_Log_Module uses this to add the Log page to each installed point types menu.
mycred/core 20 The myCRED_Hooks_Module uses this to add the Hooks page to each installed point types menu.
mycred/core 30 The myCRED_Addons_Module uses this to add the Add-ons page to the main point types menu.
mycred/badge 50 The myCRED_Badge_Module uses this to add the Badges page to the main point types menu.
mycred/banking 60 The myCRED_Banking_Module uses this to add the Banking page to the main point types menu.
mycred/purchase 70 The myCRED_buyCRED_Module uses this to add the Payment Gateways page to the main point types menu.
mycred/purchase 71 The myCRED_buyCRED_Module uses this to add the Purchase Log page to the main point types menu, if enabled.
mycred/purchase 75 The buyCRED_Pending_Payments uses this to add the Pending Payments page to the main point types menu.
mycred/coupon 80 The myCRED_Coupons_Module uses this to add the Coupons page to the main point types menu.
mycred/email 90 The myCRED_Email_Notice_Module uses this to add the Email Notifications page to the main point types menu.
mycred/rank 100 The myCRED_Ranks_Module uses this to add the Ranks page to each installed point types menu.
mycred/core 998 The myCRED_Settings_Module uses this to add the Settings page to each installed point types menu.

Examples

Example 1: Add a custom submenu page to the main point type menu.

Example 2: Add a custom submenu page for each point type menu in the admin area.

mycred_admin_enqueue

Package: mycred/core

Category: Actions

Description

This action indicates the instance where myCRED has enqueued all scripts and styling in the admin area. You can use this action hook to enqueue your own scripts or replace / dequeue scripts you do not want to be used in the admin area. 

Available since version 1.0

Parameters

Param Type Required Description
No params

Used By

Package Prio. Description
mycred/badge 50 Used by myCRED_Badge_Module to localize and enqueue scripts for the badge edit screen.
mycred/api 90 Used by myCRED_Email_Notice_Module to localize and enqueue scripts for the email notification edit screen.
mycred/rank 100 Used by myCRED_Ranks_Module to localize and enqueue scripts for the rank edit screen.

mycred_admin_init

Package: mycred/core

Category: Actions

Description

This action indicates the instance where myCRED has finished running tasks when the wp-admin area is initiated. 

Available since version 1.0

Parameters

Param Type Required Description
No params

Used By

Package Prio. Description
mycred/purchase 70 Used by myCRED_buyCRED_Module to setup exchange overrides when editing a user.
mycred/purchase 71 Used by myCRED_buyCRED_Module to register the payment gateways settings.
mycred/purchase 75 Used by buyCRED_Pending_Payments to setup all admin actions for pending point purchases.
mycred/rank 100 Used by myCRED_Ranks_Module to setup all admin actions for editing / managing ranks.

mycred_after_deletion

Package: mycred/core

Category: Actions

Description

This action indicates the instance when the myCRED plugin has been deleted. This action fires after the plugin has run it’s uninstall script, which means that all custom post types, balances and log entries have already been deleted and no longer found in your database. If you need to run tasks before this, consider using mycred_before_deletion instead. 

Available since version 1.3

Parameters

Param Type Required Description
$install obj No

The myCRED_Install class object which is used for both installations and uninstallations.

Used By

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

mycred_after_notifications

Package: mycred/core

Category: Actions

Description

This action fires after the myCRED Notifications add-on has echoed all new notifications on the front end. See also the mycred_before_notifications action. 

Available since version 1.3

Parameters

Param Type Required Description
$notifications array No

Associative array of notifications that has just been shown to the user.

Used By

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

Examples

Example 1: Show a notification indicating there is no new notifications.

mycred_banking_compound_interest

Package: mycred/banking

Category: Actions

Description

This action runs after the Compound Interest service settings, allowing you to insert custom settings or code on the settings page. 

Available since version 1.2

Parameters

Param Type Required Description
$service obj No

The Compound Interest module object.

Used By

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

Example

Example 1: Add Content after Compound Interst Settings

mycred_banking_recurring_payouts

Package: mycred/banking

Category: Actions

Description

This action runs after the Recurring Payouts service settings, allowing you to insert custom settings or code on the settings page. 

Available since version 1.2

Parameters

Param Type Required Description
$service obj No

The Recurring Payouts module object.

Used By

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

Example

Example 1: Add Content after Recurring Payouts Settings 

mycred_before_deletion

Package: mycred/core

Category: Actions

Description

This action indicates the instance when the myCRED plugin is about to be deleted. This action fires before the plugin has run it’s uninstall script, which means that all custom post types, balances and log entries are still accessible. If you need to run tasks after these details are deleted, consider using the mycred_after_deletion action instead. 

Available since version 1.3

Parameters

Param Type Required Description
$install obj No

The myCRED_Install class object which is used for both installations and uninstallations.

Used By

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

mycred_before_notifications

Package: mycred/notice

Category: Actions

Description

This action fires before the myCRED Notifications add-on has echoed all new notifications on the front end. See also the mycred_after_notifications action. 

Available since version 1.3

Parameters

Param Type Required Description
$notifications array No

Associative array of notifications that are about to be shown to the user.

Used By

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

mycred_deactivation

Package: mycred/core

Category: Actions

Description

This action indicates the instance when the myCRED plugin has been disabled. You can use this to run any necessary scripts when myCRED is not available. 

Available since version 1.0

Parameters

Param Type Required Description
No params

Used By

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

mycred_email_sent

Package: mycred/email

Category: Actions

Description

This action indicates the instance where the Email Notifications Add-on has sent an email to either your user or admin (or both). 

Available since version 1.1

Parameters

Param Type Required Description
$email array No

An associative array containing details about the email that was just sent.

Available details:

  • to – Recipients email address
  • subject – The email subject
  • message – The message body
  • headers – The email headers
  • attachments – Optional email attachments
  • request – The myCRED log entry that triggered this email notification
  • email_id – Email id (added in 1.6)

Used By

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

Example

Example 1: Count the number of email notifications that myCRED sends.

mycred_front_enqueue

Package: mycred/core

Category: Actions

Description

This action indicates the instance when scripts and styles needs to be enqueued for the front end of your website. Scripts and styles intended for the admin area can not be enqueued here! 

Available since version 1.0

Parameters

Param Type Required Description
No params

Used By

Package Prio. Description
mycred/notice 20 Used by myCRED_Notifications_Module to enqueue notification scripts and styling.
mycred/transfer 30 Used by myCRED_Transfer_Module class to register the transfer script.
mycred/core 90 Used by the myCRED_Hook_Video_Views class to register and enqueue video scripts.

mycred_init

Package: mycred/core

Category: Actions

Description

This action indicates the instance where myCRED is ready to run it’s initial actions. This action fires during WordPress’ init instance. Note that as of version 1.7, this action fires before globals are set or assets are registered.

Available since version 1.0

Parameters

Param Type Required Description
No params

Used By

All myCRED modules and hooks use this instance via the abstract class or directly from the module class. 

mycred_pre_init

Package: mycred/core

Category: Actions

Description

This action fires during “plugins_loaded” once all myCRED modules have been loaded.

Note! This action hook was moved in version 1.1.1 to the new method wp_ready().

Used By

Before version 1.3

After version 1.3

  • Function: mycred_plugin_start_up

Parameters

None 

mycred_set_user_balance

Package: mycred/core

Category: Actions

Description

This action allows you to execute custom actions when a users balance is changed to a specific amount. This action will only fire when the set_users_balance() function is used. It will not fire when the update_users_balance() function is used!

Available since version 1.7.3

Parameters

Param Type Required Description
$user_id int No

The numeric user ID.

$new_balance int or float No

The users new balance.

$old_balance int or float No

The users old balance before it was changed. (Added in 1.7.4)

$mycred obj No

The myCRED_Settings class object.

Used By

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

mycred_tool_bar

Package: mycred/core

Category: Actions

Description

This action fires directly after myCRED has added in your point balance and history link in your WordPress Toolbar, or if you are using BuddyPress, your BuddyPress Menu. You can use this to add in your own custom menus or to adjust the existing menu in any way you like.

Available since version 1.0

Parameters

Param Type Required Description
$wp_admin_bar obj Yes

The WordPress admin bar object.

Used By

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

Example

Example 1: Remove the myCRED menu in the Toolbar.

mycred_transfer_completed

Package: mycred/transfer

Category: Actions

Description

This action indicates the instance when a transfer via the Transfer add-on has been successfully completed. This action will not fire if the transaction was declined for some reason. 

Available since version 1.2

Parameters

Param Type Required Description
$transfer_id int No

A unique transaction ID, generated by the transfer add-on.

$request array No

An associative array containing the transfer request. If you need to adjust the request, consider using the mycred_new_transfer_args filter instead.

Please see the table below for all the available data.

$settings array No

The transfer add-on settings.

Request Array

Key Type Description
transaction_id string A unique transaction ID
sender_id int The numeric ID of the user that sent the transfer.
recipient_id int The numeric ID of the user that received the transfer.
reference string The reference used for the transfer.
charge int or float The point amount the sender nominated to transfer.
payout int or float The point amount the recipient received from this transfer.
point_type string The point type that was transferred.
data array Array of additional data, such as the transfer message, if allowed.

Used By

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

mycred_transfer_ready

Package: mycred/transfer

Category: Actions

Description

This action indicates the instance where the Transfer add-on is ready to process a validated transfer request. You can use this to execute actions before the processing or make further validations of the request.

 

This action fires only during an AJAX call and not on regular page loads so if you need to stop / decline a transaction you will need to use wp_send_json_error or similar.

Available since version 1.2

Parameters

Param Type Required Description
$transfer_id int No

A unique transaction ID, generated by the transfer add-on.

$request array No

An associative array containing the transfer request. If you need to adjust the request, consider using the mycred_new_transfer_request filter instead.

Available details:

  • token – The WordPress nonce used for this request
  • recipient_id – The numeric ID of the user intended as the recipient of this transfer
  • ctype – The point type key being transferred
  • amount – The amount being transferred
  • reference – The reference under which this transfer will be logged

$settings array No

The transfer add-on settings.

Used By

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

Example

Example 1: Make sure subscribers transfer minimum 100 points. All other users must transfer the amount set in the settings.

mycred_twilio_action_$action

Package: mycred/twilio

Category: Actions

Description

This action allows you to execute custom code for custom transfer action keywords. This can be utilized to create custom keywords besides the built-in ones. 

Available since version 1.0

Parameters

Param Type Required Description
$sms_message array No

The SMS message body split into an array.

$module obj No

The Twilio Transfer module object.

Used By

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

Example

Example 1: Example of how to intercept custom transfer actions using the Twilio Transfers plugin.

mycred_twilio_after_prefs

Package: mycred/twilio

Category: Actions

Description

This action allows you to insert custom settings for the Twilio Transfers plugin.

Available since version 1.0

Parameters

Param Type Required Description
$settings array No

Associative array of settings currently in use by the plugin.

$module obj No

The Twilio transfer plugin module.

Used By

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

mycred_twilio_incoming_sms

Package: mycred/twilio

Category: Actions

Description

This action allows you to execute custom code when the plugin detects an incoming Webhook message. By the time this action fires, the plugin will have validated the Twilio Account SID and phone number.

Available since version 1.0

Parameters

Param Type Required Description
$sms_message array No

The SMS message body split into an array.

$module obj No

The Twilio Transfer module object.

Used By

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

mycred_twilio_transfer_cancelled

Package: mycred/twilio

Category: Actions

Description

This action allows you to execute custom code when a Twilio transfer has been successfully cancelled (if allowed). This action runs after the transfer cancellation has completed but before an SMS reply is sent to Twilio.

Available since version 1.0

Parameters

Param Type Required Description
$transaction_id int No

A unique transaction ID.

$request array No

The transfer request array that was successfully processed.

$module obj No

The Twilio Transfer module object.

Used By

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

mycred_twilio_transfer_finished

Package: mycred/twilio

Category: Actions

Description

This action allows you to execute custom code when a Twilio transfer has finished successfully. This action runs after the transfer has completed but before an SMS reply is sent to Twilio. 

Available since version 1.0

Parameters

Param Type Required Description
$transaction_id int No

A unique transaction ID.

$request array No

The transfer request array that was successfully processed.

$module obj No

The Twilio Transfer module object.

Used By

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

mycred_update_user_balance

Package: mycred/balance

Category: Actions

Description

This action allows you to execute custom actions when a users balance changes. Note that this action fires after a users balance has been updated and not before. Also no transaction details are available besides the users ID, the amount gained / lost and the point type. 

Available since version 1.1

Parameters

Param Type Required Description
$user_id int No

The ID of the user.

$current_balance - No

The users “current balance” before it was adjusted.

$amount - No

The amount added or deducted from the users current balance. A positive value represents point gains while negative value represents point loss.

$type string No

The point type.

Used By

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

Example

Example 1: Send admin an email when a users balance reaches 10000.

mycred_user_got_demoted

Package: mycred/rank

Category: Actions

Description

This action hook fires each time a user has been demoted to a rank that has a lower minimum point requirement set then their previous rank. For promotions, please see the mycred_user_got_promoted action.

In most cases, this action fires during the point payout / deduction process. For this reason, you can not use any function that adds or deducts points from a users account e.g. mycred_add or mycred()->add_creds(). If you do, you will create an infinite loop!

Available since version 1.4

Parameters

Param Type Required Description
$user_id int No

The ID of the user that is affected by this demotion.

$rank_id int No

The rank post ID that the user was demoted to.

$results obj No

The database requests that caused this action to fire. (Added in 1.7).

Available details:

  • rank_id – The new rank ID the user has reached
  • current_id – The ID of the users current rank that they will lose
  • minimum – The new ranks set minimum balance requirement
  • maximum – The new ranks set maximum balance requirement

Used By

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

Example

Example 1: When a user is demoted to a lower rank, we penalize them by deducting 10 points from their account.

mycred_user_got_promoted

Package: mycred/rank

Category: Actions

Description

This action hook fires each time a user has been promoted to a rank that has a higher minimum point requirement set then their previous rank. For demotions, please see the mycred_user_got_demoted action.

In most cases, this action fires during the point payout / deduction process. For this reason, you can not use any function that adds or deducts points from a users account e.g. mycred_add or mycred()->add_creds(). If you do, you will create an infinite loop!

Available since version 1.4

Parameters

Param Type Required Description
$user_id int No

The ID of the user that is affected by this promotion.

$rank_id int No

The rank post ID that the user was promoted to.

$request obj No

The database requests that caused this action to fire. (Added in 1.7).

Available details:

  • rank_id – The new rank ID the user has reached
  • current_id – The ID of the users current rank that they will lose
  • minimum – The new ranks set minimum balance requirement
  • maximum – The new ranks set maximum balance requirement

Used By

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

Example

Example 1: When a user reaches the rank with the ID 123, we give them a 10 point bonus.

mycred_widgets_init

Package: mycred/core

Category: Actions

Description

This action fires once myCRED has loaded and registered all widgets. 

Used By

Before version 1.3

Afer version 1.3

  • Function: mycred_widgets_init

Parameters

None 

Share this Doc
CONTENTS