mycred_update_user_balance

Codex / mycred/balance / Actions / mycred_update_user_balance

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