mycred_add_menu

Package: mycred/core Category: Actions

Navigation:

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

Description

This action fires once myCRED has created the admin menu. Used by any module that requires an admin menu link.

 

Used By

 

Parameters

 

Example

Example: Add a sub menu item called “Custom”.

<?php
add_action( 'mycred_add_menu', 'my_custom_sub_menu' );
function my_custom_sub_menu( $mycred )
{
	add_submenu_page(
		'myCRED',
		__( 'Custom' ),
		__( 'Custom' ),
		$mycred->edit_plugin_cap(),
		'my_custom_page_slug',
		'my_custom_page'
	);
}
?>

Last edited March 5, 2016

Back To Top

mycred_admin_enqueue

Package: mycred/core Category: Actions

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This action fires once myCRED has registered and enqueued core scripts and styles for the admin area. For more information see admin_enqueue_scripts.

 

Used By

 

Parameters

None

Last edited March 5, 2016

Back To Top

mycred_admin_init

Package: mycred/core Category: Actions

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This action fires once myCRED has run its admin_init functions.

 

Used By

 

Parameters

None

Last edited March 5, 2016

Back To Top

mycred_after_deletion

Package: mycred/core Category: Actions

Navigation:

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

Description

This action fires when the plugin has been selected to be deleted and myCRED has runs its own deletion process. This is the last action run by myCRED.

 

Used By

 

Parameters

  • install (object)
    The myCRED_Install Class Object.

Last edited March 7, 2016

Back To Top

mycred_after_notifications

Package: mycred/notice 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.2

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 ``No new notifications`` message if a use does not have any notifications.

add_action( 'mycred_after_notifications', 'mycredpro_after_notifications' );
function mycredpro_after_notifications( $notifications ) {

	if ( empty( $notifications ) )
		echo '<!-- Notice --><script type="text/javascript">(function(jQuery){jQuery.noticeAdd({ text: "No new notifications",stay: true });})(jQuery);</script>';

}

Last edited March 6, 2016

Back To Top

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.

Examples

Example 1: Insert text on the service settings page.

add_action( 'mycred_banking_compound_interest', 'mycredpro_comp_service_prefs' );
function mycredpro_comp_service_prefs( $service ) {

	echo '<p>Custom text.</p>';

}

Last edited March 7, 2016

Back To Top

mycred_banking_do_payout

Package: mycred/banking Category: Actions

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This action runs for each user after a payout (or charge) has been made by a service in the Banking add-on.

 

Used By

  • Class: myCRED_Banking_Service_Interest Method: do_payout()
  • Class: myCRED_Banking_Service_Payouts Method: do_payout()

 

Parameters

  • service_id (string)
    The id of the current service that is running.
  • user_id (int)
    The ID of the user currently being processed.
  • prefs (array)
    This services preferences.

Last edited March 7, 2016

Back To Top

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.

Examples

Example 1: Insert text on the service settings page.

add_action( 'mycred_banking_recurring_payouts', 'mycredpro_recu_service_prefs' );
function mycredpro_recu_service_prefs( $service ) {

	echo '<p>Custom text.</p>';

}

Last edited March 7, 2016

Back To Top

mycred_before_deletion

Package: mycred/core Category: Actions

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This action fires when the plugin has been selected to be deleted but before myCRED runs its own deletion process.

 

Used By

 

Parameters

  • install (object)
    The myCRED_Install Class Object.

Last edited March 7, 2016

Back To Top

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

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.

Examples

Example 1: Show a ``No new notifications`` message if a use does not have any notifications.

add_action( 'mycred_before_notifications', 'mycredpro_before_notifications' );
function mycredpro_before_notifications( $notifications ) {

	if ( empty( $notifications ) )
		echo '<!-- Notice --><script type="text/javascript">(function(jQuery){jQuery.noticeAdd({ text: "No new notifications",stay: true });})(jQuery);</script>';

}

Last edited March 6, 2016

Back To Top

mycred_deactivation

Package: mycred/core Category: Actions

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This action fired when the myCRED plugin is de-activated. Plugins using myCRED should use this action to delete or de-activate custom features.

 

Used By

  • Class: myCRED_Install

 

Parameters

None

Last edited March 7, 2016

Back To Top

mycred_email_sent

Package: mycred/email Category: Actions

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This action fires after an email notice has been sent using wp_mail().

Requires the Email Notices Add-on to be enabled.

 

Used By

  • Class: myCRED_Email_Notices Method: wp_mail()

 

Parameters

  • notice (array)
    The email notice details as formated by the mycred_email_before_send filter in an associative array format. Available array keys:
    • to (string)
      Recipients Email address.
    • subject (string)
      Email subject.
    • message (string)
      The parsed email message body.
    • headers (array)
      Email headers.
    • attachments (string)
      Email attachments.
    • request (array)
      The initial request when points are awarded or deducted from the users account. For more information consult the mycred_add filter.
    • email_id (int)
      The email notice id.

Last edited March 7, 2016

Back To Top

mycred_front_enqueue

Package: mycred/core Category: Actions

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This action fires once myCRED has registered and enqueued core scripts and styles for the front. For more information see wp_enqueue_scripts.

 

Used By

 

Parameters

None

Last edited March 5, 2016

Back To Top

mycred_init

Package: mycred/core Category: Actions

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This action fires once myCRED has run its init functions.

 

Used By

Before version 1.3

After version 1.3

  • Function: mycred_init

 

Parameters

None

Last edited March 5, 2016

Back To Top

mycred_pre_init

Package: mycred/core Category: Actions

Navigation:

  1. Description
  2. Used By
  3. Parameters

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

Last edited March 5, 2016

Back To Top

mycred_tool_bar

Package: mycred/core Category: Actions

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This action fires once myCRED has adjusted the Tool Bar.

Note! This action will not fire if BuddyPress is installed and active!

 

Used By

 

Parameters

Last edited March 5, 2016

Back To Top

mycred_transfer_completed

Package: mycred/transfer Category: Actions

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This action fires after a transfer has been executed.

Requires the Transfer Add-on to be enabled.

When this action fires, you can access the following transfer arguments:

  • Recipient $_POST['recipient']
    The transfer recipients user id.
  • Sender $_POST['sender'] (int)
    The transfer senders user id.
  • Amount $_POST['amount'] (int|float)
    The transfer amount.

 

Used By

  • Class: myCRED_Transfer_Creds Method: ajax_call_transfer()

 

Parameters

  • prefs (array)
    Associative array of the Transfer Add-ons settings.
  • mycred (object)
    The myCRED_Settings Class Object.

Last edited March 7, 2016

Back To Top

mycred_transfer_ready

Package: mycred/transfer Category: Actions

Navigation:

  1. Description
  2. Used By
  3. Parameters

Description

This action can be used to terminate or execute custom code when a new transfer request is made. This action will fire first when a user has met the core requirements for a new transfer. These core requirements are:

  • The transfer recipient exists and is not excluded from getting points.
  • The transfer add-on has been setup in the admin area.
  • The sender has sufficient funds for this transfer.

 

Used By

  • Class: myCRED_Transfer_Creds Method: ajax_call_transfer()

 

Parameters

Note that these parameters were changed in version 1.5. Older myCRED versions will not have these parameters available!
  • transaction_id (string)
    A unique transaction ID generated by myCRED.
  • post (array)
    An associative array of form fields submitted. Basically everything that got sent via $_POST after the values have been sanitized.
  • prefs (array)
    The transfer add-on preferences.
  • transfer_addon (object)
    The Transfer Module object. You can use this to access class methods like get_recipient().
  • type (string)
    The point type being transferred.

Remember that this action fires during an AJAX call so if you want to stop a transfer, you can use:

die( json_encode( 'myerror' ) );

If you want to add a custom transfer error / success message, please use the mycred_transfer_messages filter to add your message in clear text (what users see) and instead use the above code to return the unique error code (not visible to users).

Last edited March 7, 2016

Back To Top

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.

Examples

Example 1: Send an email to administrator when a user reaches 10,000 points.

add_action( 'mycred_update_user_balance', 'mycredpro_email_tentousand', 10, 4 );
function mycredpro_email_tentousand( $user_id, $current_balance, $amount, $type ) {

	if ( $amount > 0 && $current_balance + $amount >= 10000 ) {

		$subject = '10,000 Points Reached!';
		$message = 'A user has reached 10,000 points!';
		wp_mail( get_option( 'admin_email' ), $subject, $message );

	}

}

Last edited March 7, 2016

Back To Top

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.

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.

Used By

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

Examples

Example 1: Deduct 10 points from users that gets demoted as a penalty.

add_action( 'mycred_user_got_demoted', 'mycredpro_penalty_for_lower_rank', 10, 2 );
function mycredpro_penalty_for_lower_rank( $user_id, $rank_id ) {

	mycred_add(
		'penalty',
		$user_id,
		0 - 10,
		'Penalty for rank demotion'
	);

}

Last edited March 5, 2016

Back To Top

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.

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.

Used By

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

Examples

Example 1: Give 10 bonus points to users that reach a rank with the ID 123.

add_action( 'mycred_user_got_promoted', 'mycredpro_bonus_for_new_rank', 10, 2 );
function mycredpro_bonus_for_new_rank( $user_id, $rank_id ) {

	if ( $rank_id !== 123 ) return;

	mycred_add(
		'bonus_points',
		$user_id,
		10,
		'Bonus for reaching "Legend" rank'
	);

}

Last edited March 5, 2016

Back To Top

mycred_widgets_init

Package: mycred/core Category: Actions

Navigation:

  1. Description
  2. Used By
  3. Parameters

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

Last edited March 5, 2016

Back To Top

Last edited June 5, 2016